php version 5.4.33 php.ini: bcmath.scale = 0 (also tried bcmath.scale = PHP_INI_ALL)
problem:
php5433 -r "echo bccomp(0.00000001, 0, 9);" print 0
php5433 -r "echo bccomp(1.00000001, 1, 9);" print 1
why? Anyone can help?
php version 5.4.33 php.ini: bcmath.scale = 0 (also tried bcmath.scale = PHP_INI_ALL)
problem:
php5433 -r "echo bccomp(0.00000001, 0, 9);" print 0
php5433 -r "echo bccomp(1.00000001, 1, 9);" print 1
why? Anyone can help?
it's because bccomp
first 2 arguments are meant to be strings. as you can see here when they are strings it works as expected. why is this? i'm not sure but it probably has something to with why echo 0.00000001;
outputs 1.0E-8 (the Scientific notation) while echo 1.00000001;
outputs 1.00000001 (example)
bcmath.scale = 0
only sets the default scale value when it's not supplied like bcscale
Sets the default scale parameter for all subsequent calls to bc math functions that do not explicitly specify a scale parameter.