Re: Big Integer Atoms

new topic     » goto parent     » topic index » view thread      » older message » newer message

Carl White wrote:

------
> From: Carl W. <euphoria at cyreksoft.yorks.com>
> To: EUforum at topica.com
> Subject: Re: Big Integer Atoms
> Sent: 12 jul 2004 y. 12:20
> 
> 
> Igor Kachan wrote:
> > 
> > Hi, dear Euphorians,
> > 
> > The EU manual says:
> > 
> > "... Those declared with type integer must be atoms 
> > with integer values from -1073741824 to +1073741823
> > inclusive. 
> > You can perform exact calculations on larger integer
> > values, up to about 15 decimal digits, but declare 
> > them as atom, rather than integer ..."
> > 
> > This "up to about 15 decimal digits" seems to be not
> > enough concrete thing for some cases.
> > 
> > Couldn't someone tell me about more precise
> > bounds of these "larger integer values"?
> 
> The IEEE 64-bit floating point number, known to us as the Euphoria atom, 
> is made up from one sign bit, ten exponent bits, and 53 mantissa bits.
> 
> This means (IIRC) that you can accurately represent all the integers 
> from -power(2^53) to +power(2,53) (-9007199254740992 to 
> 9007199254740992). The fact that power(2,53) is representable is a bit 
> of a fluke as the last bit of its binary representation isn't stored (54 
> bits are needed, yet it is stored in 53).
> 
> You can prove it with this little bit of code:
> }}}
<eucode>
> atom x
> x = power(2,53)-100
> while x != x + 1 do
>     ? x
>     x += 1
> end while
> </eucode>
{{{

> 
> It looks like it loops forever (a number is never equal to one more than 
> itself), but it actually stops at the largest representable integer.

Thanks Carl! I think, I'll catch this floating animal now.

Good Luck!

Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu