Carey Brown wrote:This will give you an idea as to how the overflow is affecting the return value. Note that longs are 16 hex-digits long. And, once you have a return value of zero, well, zero times anything is zero.
n=65 fact=-9223372036854775808 (0x8000000000000000) ret=-9223372036854775808 (0x8000000000000000) bigret=-599519182395560427520 (0x-208000000000000000)
n=66 fact=-9223372036854775808 (0x8000000000000000) ret= 0 (0x 0) bigret=-608742554432415203328 (0x-210000000000000000) // lower 16 nibbles all zero
n=67 fact= 0 (0x 0) ret= 0 (0x 0) bigret= 0 (0x0)[/tt]
Lucian Whiteman wrote:I do not get it: does JVM make the * operation on hexa numbers ? Does it not make it on binary digits numbers ?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |