You are here: Re: really big integer « PHP Programming Language « IT news, forums, messages
Re: really big integer

Posted by Oli Filth on 03/17/06 22:16

julian_m said the following on 17/03/2006 20:02:
> I need to calculate the sum of the following numbers
>
> 1+ 11 + 111 + 1111 + ......+ 1111.....11111 (the last one is a number
> made by 2002 1's )
>
> so, I wrote
>
<...SNIP...>
> All works pretty well, and after a really small piece of time, I get:
>
> 1.2345679012346E+308
>
> but the result seems to be wrong
> Can anyone point me where is the mistake?


You can't fully represent a number with 2000-ish significant digits with
normal integers or floats, nor can you represent a number bigger than
~10^308 with floats. So that's two reasons why this doesn't work!

You'll need to use an arbitrary-length integer library, e.g. BCMath.


--
Oli

 

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

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