Integer overflow: Difference between revisions
Content added Content deleted
(→{{header|PARI/GP}}: crashing a t_INT) |
|||
Line 1,794: | Line 1,794: | ||
Additionally, you can, in principle, overflow a <code>t_INT</code>. The length, in words, of a <code>t_INT</code> is given in a single word. Hence on 32 bit a <code>t_INT</code> cannot have more than 2^32-1 words, limiting it to the range |
Additionally, you can, in principle, overflow a <code>t_INT</code>. The length, in words, of a <code>t_INT</code> is given in a single word. Hence on 32 bit a <code>t_INT</code> cannot have more than 2^32-1 words, limiting it to the range |
||
:<math>\{-(2^{2^{32}-1}-1), -(2^{2^{32}-1}-2), \ldots, -2, -1, 0, 1, 2, \ldots, 2^{2^{32}-1}-2, 2^{2^{32}-1}-1\}</math> |
:<math>\{-(2^{2^{32}-1}-1), -(2^{2^{32}-1}-2), \ldots, -2, -1, 0, 1, 2, \ldots, 2^{2^{32}-1}-2, 2^{2^{32}-1}-1\}</math> |
||
or |
|||
⚫ | |||
:<math>\{-(2^{2^{64}-1}-1), -(2^{2^{64}-1}-2), \ldots, -2, -1, 0, 1, 2, \ldots, 2^{2^{64}-1}-2, 2^{2^{64}-1}-1\}</math> |
:<math>\{-(2^{2^{64}-1}-1), -(2^{2^{64}-1}-2), \ldots, -2, -1, 0, 1, 2, \ldots, 2^{2^{64}-1}-2, 2^{2^{64}-1}-1\}</math> |
||
⚫ | |||
(Note that these bounds are different from an IEEE 754-style floating point because the sign bit is stored externally.) It takes > 18 exabytes to overflow a <code>t_INT</code> on 64-bit (roughly Google's total storage as of 2014), but it's doable in 32-bit. Has anyone tried? I imagine you'd get a memory error or the like. |
(Note that these bounds are different from an IEEE 754-style floating point because the sign bit is stored externally.) It takes > 18 exabytes to overflow a <code>t_INT</code> on 64-bit (roughly Google's total storage as of 2014), but it's doable in 32-bit. Has anyone tried? I imagine you'd get a memory error or the like. |