You are here: Re: Variable value gets rounded off « PHP Programming Language « IT news, forums, messages
Re: Variable value gets rounded off

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация