Integer comparison bug

Started by genghis, April 12, 2012, 09:03:35 AM

Previous topic - Next topic

genghis

Loving the language so far.



(= 9223372036854775807 9223372036854775808)

The above returns true. Shouldn't it be nil instead? Where can I submit bug reports? Do we have an bug tracker?

Lutz

#1
Integers are limited to 63-bit plus sign bit. Bigger numbers are truncated:



> 9223372036854775807
9223372036854775807
> 9223372036854775808   ; <-- will get truncated
9223372036854775807
>


only on negative numbers you can reach the 8 at the end:



> (= -9223372036854775807 -9223372036854775808)
nil
> (bits 9223372036854775807)
"111111111111111111111111111111111111111111111111111111111111111"
> (length (bits 9223372036854775807))
63
> (bits -9223372036854775808)
"1000000000000000000000000000000000000000000000000000000000000000"
> (length (bits -9223372036854775808))
64
>

xytroxon

#2
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/comments/s6477/9223372036854775807_9223372036854775808/">//http://www.reddit.com/r/programming/comments/s6477/9223372036854775807_9223372036854775808/





The above link expounds on the issue...



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976