php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66745 Scientific notation
Submitted: 2014-02-20 08:32 UTC Modified: 2017-09-07 22:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: eric dot vercherat at gmail dot com Assigned: cmb (profile)
Status: Closed Package: BC math related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: eric dot vercherat at gmail dot com
New email:
PHP Version: OS:

 

 [2014-02-20 08:32 UTC] eric dot vercherat at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/ref.bc
---


It's not mentioned in the documentation that BC Math doesn't support scientific notation.

Please make something about it.

Test script:
---------------
$a = '1' ;
$b = '0.00000001';

$result = bcdiv($a, $b);
var_dump($result);

$a =  '1' ;
$b =  '1e-8';

$result = bcdiv($a, $b);
var_dump($result);

Expected result:
----------------
string(40) "100000000.000000000000000000000000000000" 

Actual result:
--------------
Warning: bcdiv() [function.bcdiv]: Division by zero in C:\wamp\www\utilitaires\test_bcdiv.php on line 17
NULL 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-03 16:41 UTC] tycoonmaster at gmail dot com
I do not know if this is intentional or merely an oversight but I encounter this problem, constantly, every day. So far the easiest solution has been to format the string:
$number = number_format($number, 8, '.', '');
prior to passing it into BC functions.

Are there any patches/fixes for this in the future?
Or will I and so many others, need to constantly work around this issue?

Example: http://www.php.net/manual/en/ref.bc.php#92888
 [2014-07-03 17:46 UTC] aharvey@php.net
A pull request would be welcome, I'm sure.
 [2016-07-13 23:55 UTC] cmb@php.net
Related to bug #66959.
 [2017-09-07 22:23 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=343020
Log: Fix bug #66745: Scientific notation

We document that float to string is problematic for BCMath.
 [2017-09-07 22:24 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=b5397d3cda32e834970114d17dec0e05493cafe8
Log: Fix bug #66745: Scientific notation
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC