Page 1 of 1
Integer comparison bug
Posted: Thu Apr 12, 2012 4:03 pm
by genghis
Loving the language so far.
Code: Select all
(= 9223372036854775807 9223372036854775808)
The above returns true. Shouldn't it be nil instead? Where can I submit bug reports? Do we have an bug tracker?
Re: Integer comparison bug
Posted: Thu Apr 12, 2012 4:39 pm
by Lutz
Integers are limited to 63-bit plus sign bit. Bigger numbers are truncated:
Code: Select all
> 9223372036854775807
9223372036854775807
> 9223372036854775808 ; <-- will get truncated
9223372036854775807
>
only on negative numbers you can reach the 8 at the end:
Code: Select all
> (= -9223372036854775807 -9223372036854775808)
nil
> (bits 9223372036854775807)
"111111111111111111111111111111111111111111111111111111111111111"
> (length (bits 9223372036854775807))
63
> (bits -9223372036854775808)
"1000000000000000000000000000000000000000000000000000000000000000"
> (length (bits -9223372036854775808))
64
>
Re: Integer comparison bug
Posted: Thu Apr 12, 2012 5:54 pm
by xytroxon
Yeah, this showed up on reddit/programming about a PHP "bug"...
'9223372036854775807' == '9223372036854775808' (bugs.php.net)
submitted 4 hours ago by tjansson
* 143 comments
http://www.reddit.com/r/programming/com ... 854775808/
The above link expounds on the issue...
-- xytroxon