• Subject: Re: big integers
• From: bb <bblochl@...>
• Date: Sat, 23 Jan 2010 21:56:30 +0100

```spir schrieb:
```
```On Sat, 23 Jan 2010 20:34:39 +0100
spir <denis.spir@free.fr> wrote:

```
```Hello,

Is "maxInt == 1e14-1" true? (found by trying to display -- higher values get exp notation)
```
```
PS: Just read at http://stackoverflow.com/questions/945731/what-is-the-maximum-value-of-a-number-in-lua that the mantissa is 52-bit wide. This should allow slightly bigger integers, no? (0xfffffffffffff ~ 4.5035996273705e+15, if I'm right)

```
```Is there any available tool for bigger (accurate) integers / for arbitrary long integers?
```
```
I will need integers which width is n*24 bits, where n is not yet known, but for sure >= 3.

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/

```
```In lua/llimits.h you find (a code snippet):
...
00018 /*
00019 ** try to find number of bits in an integer
00020 */
00021 #ifndef BITS_INT
00022 /* avoid overflows in comparison */
00023 #if INT_MAX-20 < 32760
00024 #define BITS_INT        16
00025 #else
00026 #if INT_MAX > 2147483640L
00027 /* machine has at least 32 bits */
00028 #define BITS_INT        32
00029 #else
00030 #error "you must define BITS_INT with number of bits in an integer"
00031 #endif
00032 #endif
00033 #endif
...

So it is clear, that "maxInt == 1e14-1" never can be true!

```
2^32 = 4294967296, that means you have a limit of 2147483648 in two complement representation (because of the bisectioning of the binary number circle to + and - sign) say a representation of positive numbers 0 to +2147483647 and negative numbers -1 to -2147483648, that is much smaller than the 1e14-1 you expected. From where did you get that huge number? May be you mixed up integer representation and IEEE floating point format?
```
```
May be I completely misunderstand your posting and your goal with the equality test? BTW, an equality test with other formats as integer always is eval, better use barriers.
```Example:
for (i=0.0; i==1; i+=0.1) {...} - looks fine.

```
A float representation of 1.0 usually gives 0.99999999 in a bunary representation and 0.999999999 == 1 ? True or false?
```
Regards BB

```