BCMath is used to perform arithmetic calculations within Fraction class methods. This enables better precision than PHP float value arithmetic.
Currently, many of the BCMath function calls in fraction.class.inc do not set a scale parameter, which means the scale will default to whatever the global default scale is. If no default global scale is set, it defaults to zero. Fraction needs to use a scale of zero to ensure that the numerator/denominator are always whole numbers. If the scale is set globally using bcscale, then this assumption is broken. So we should explicitly set the scale to zero wherever it is used.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2921422-5.patch | 2.87 KB | pcambra |
| |||
#2 | fraction_bcmath_scale-2921422-2.patch | 2.88 KB | m.stenta |
Comments
Comment #2
m.stentaCommitted.
Attached is the patch. Needs to be ported to 8.x-1.x.
Comment #3
m.stentahttp://cgit.drupalcode.org/fraction/commit/?id=add0600
Comment #5
pcambraComment #7
m.stentaMerged - thanks @pcambra!