in reply to Integer overflow question
The largest representable unsigned integer is ~0, the largest signed integer is (~0-1)/2.
If you use floating point numbers (too large integers get converted to floating point numbers automatically), however, you have a higher upper limit. If $f = 1; $f *= 2 until $f * 2 == $f * 2 - 1; than you can increment the counter up to $f, but no more. $f is 9007199254740992 on my machine. However, you have to print these with printf "%.0f", not simple print, or you'll lose precision when printing.
|
|---|