Crystal: i64 literal might not be allowing all values

Created on 29 Oct 2019  路  4Comments  路  Source: crystal-lang/crystal

I think 0x8000000000000000_i64 should evaluate to -9223372036854775808. It seems like it does not check for sign and then fails because the max is positive number is 9223372036854775807.

https://play.crystal-lang.org/#/r/7wmr

Most helpful comment

@wontruefree Number literals use regular math notation, not a binary data format. See https://forum.crystal-lang.org/t/negative-numbers-in-binary-and-hexa/1062/5?u=straight-shoota for the difference.

All 4 comments

First sentence makes no sense to me already.

0x80000000_i32
Error: 2147483648 doesn't fit in an Int32

@wontruefree Number literals use regular math notation, not a binary data format. See https://forum.crystal-lang.org/t/negative-numbers-in-binary-and-hexa/1062/5?u=straight-shoota for the difference.

@straight-shoota that makes sense. I was working on a c port and that is treated a little different.

Was this page helpful?
0 / 5 - 0 ratings