haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Wrong UInt max value ?

Open flashultra opened this issue 7 years ago • 3 comments

Class UInt is available on all platforms, but if you try to assign value more than 2147483647 ( ‭7FFFFFFF‬ ) you will get the error " Float should be UInt". Maybe max value for UInt should be 4294967295 ( ‭FFFFFFFF‬ ) or I miss something ?

Example: https://try.haxe.org/#Bd879 or https://try.haxe.org/#527b0

flashultra avatar Oct 10 '18 13:10 flashultra

The thing is that UInt is an abstract over Int, but values bigger than 0x7FFFFFFF are not representable as int literals in decimal format.

Maybe this example explains better what I mean: https://try.haxe.org/#5dd2d

azrafe7 avatar Oct 10 '18 14:10 azrafe7

This will have to be reviewed as part of bigger changes related to more large integer literals support (including int64)

ncannasse avatar Oct 10 '18 19:10 ncannasse

Just hit this. It turns out that if you specify your literal in hex 0xffffffffu32 then it will load the value. Thanx to CRobes on the discord for that.

47rooks avatar Oct 18 '25 22:10 47rooks