I solved the task, but I'm not sure how casting 150,000 as a short turns the number into 18,928.
why does (short) 150,000 print 18,928
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Thomas
14 May 2021, 19:39useful
150_000 is an int and in binary notation:
000000_00000010_01001001_11110000
If you cast that to a short, then this means you cut off the first two bytes and that results in:
01001001_11110000
and that again is the value 18_928
+1