|
Posted by Tim Roberts on 01/03/08 08:50
Lawrence <lawbuji@gmail.com> wrote:
>On Jan 3, 10:34 am, Michael Fesser <neti...@gmx.de> wrote:
>> .oO(Lawrence)
>>
>> >hi all, while im computing large values the variable value gets
>> >rounded off to the next higher value .How do we stop or prevent this
>> >happening.
>>
>> How large is "large"? What about a code example?
>>
>> Micha
>
>$a=$b+$c+$d
>where $b=99999999999999
> $c=99999999999999
> $d=99999999999999
When a number gets too large for a 32-bit integer, PHP switches to floating
point. An IEEE-754 floating point value holds just over 15 digits of
precision. $b, $c and $d fit, but $a does not. Hence, you lose precision.
If you need arbitrary precision mathematics, look at the BCMath functions
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Navigation:
[Reply to this message]
|