PHP :: Doc Bug #66745 :: Scientific notation
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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Aug 15 20:01:25 2018 UTC