[Cs254f11] safe casting
Wm. Josiah Erikson
josiah at insanetechnology.com
Thu Dec 8 14:20:57 EST 2011
Hey guys,
I was having trouble with my error routine occasionally throwing
things like "IllegalArgumentException
java.lang.IllegalArgumentException: Value out of range for long" because
I was casting things to an int first (then I got lots of errors like
this), then to a long (in an attempt to get rid of the problem), because
I wanted to remove the decimals, but then I discovered unchecked-int,
which casts to an int and just truncates it if it doesn't fit. Nice. And
fine, since it's just the output of my error routine, and if that is too
big to fit in an int, well then it's just really really bad, and we
already knew that :)
In case it's helpful for anyone else.
-Josiah
More information about the Cs254f11
mailing list