shouldnt postfix `u` help maybe? (this works thou...
# announcements
e
shouldnt postfix
u
help maybe? (this works though
(0xffff shl 48)
)
c
Put an L at the end of your 0xfff... number to declare it as a long. But I think it still doesn't fit in a long, does it?
u
It fits inside unsigned long, which the suffix U should signify, but I think unsigned numbers are still experimental
But you are right, that with signed long, 0xffff... is an overflow
@elect If you really need it to be Long, and don't mind that it overflows this would give you what you expect at least as far as bits inside it go
Copy code
val l = ((value.toULong() shl 48) and 0xFFFF_0000_0000_0000UL).toLong()
This should work as well
Copy code
val l = ((value.toLong() and 0xFFFF) shl 48)