You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BigDecimal::of(0.0001)->getScale() is 4
BigDecimal::of(0.00001)->getScale() is 6
i find that "BigDecimal::of(0.00001)" the value is 10, and the scale is 6.
Can the value is 1, and the scale is 5 ?
The text was updated successfully, but these errors were encountered:
Note that in this case, only the scale differs, the values are still equal:
var_export($a->isEqualTo($b)); // true
Where does the extra digit come from?
In this particular case, the reason is not a rounding error (a common issue with floating point numbers), but the fact that the value is converted to a string, then parsed:
echo (string) 0.00001; // 1.0E-5
The fact that it returns a number with value 10 and scale 6 is consistent with the fact that for the number 1.1E-5, one would expect value 11 and scale 6.
On the other hand, 1E-5 would return what you expect:
BigDecimal::of(0.0001)->getScale() is 4
BigDecimal::of(0.00001)->getScale() is 6
i find that "BigDecimal::of(0.00001)" the value is 10, and the scale is 6.
Can the value is 1, and the scale is 5 ?
The text was updated successfully, but these errors were encountered: