floating point - PHP & Base 2. Which Floats give a precise Value? -
apologies poor maths skills, i've tried understand answer own query i'm not convinced.
we know php doesn't store floats in base 10 base 2.
i have series of calculations using 0.5 float, , in trying understand if stored 0.500001 or 0.4999999 (for rounding purposes there big difference!!!) have come understand 0.5 stored precisely in base2.
my queries
a have understood correctly?
b other floats stored precisely in base2? eg 0.25?
any multiple of 1/pow(x, 2) can precisely represented float.
that means x/2, x/4, x/8, x/16 ...ect. can accurately represented.
for more information on how floating point numbers store see http://kipirvine.com/asm/workbook/floating_tut.htm
gmp library high precision math.
Comments
Post a Comment