```(-1L).toULong()``` That's ugly :sad-panda: Wind...
# random
e
Copy code
(-1L).toULong()
That's ugly sad panda Windows interop gone crazy AH, WAIT!
Copy code
(-1L).toULong() == ULong.MAX_VALUE
p
It seems that each platform uses a different integer binary bit representation. Is a good call out 👍
✔️ 2
k
What's strange about it? I'm not using Windows right now, but I always thought it was 64-bit two's complement, like most platforms.
p
I believe it uses twos complement. 111 = -1 which seeing from an unsigned perspective is the biggest possible value. Now is confusing, I consider this should throw or warn, since it is kinda converting something that is negative, and has no representation in the unsigned domain.
k
I think this is the correct behaviour as it is consistent with all other forms of integer casting in which the original number is outside the domain of the target. For example,
257.toByte()
== 1
p
Got it, makes sense tbh, is basically some of us not knowing the overflow/casting rules