On Monday 17 Nov 2003 6:17 pm, James Sparenberg wrote:
> Older Linux's have been recently discovered to count uptime to 497 days
> then using a new form of math 497 + 1 = 0 .   I'm not sure but I think
> it has something to do with a Honeywell emulation layer. (For those who
> don't know Honeywell(IFRC) mainframes had both -0 and +0, and although
> -0 = +0, (0-1) != (-0+1)  go figure)

One's complement arithmetic. To negate a number you just invert all the bits.
So zero is represented as both 111...111 and 000...000.
These days we use two's complement, where to negate a number you invert all 
the bits and add one. There's only one zero, but an extra negative number 
that doesn't have a positive representation: 100...000.
So the range of an eight bit signed number is -128 to +127.
In eight bit two's complement arithmetic -(-128) = -128 go figure ;-)

Of course, that doesn't anything to do with it though. A simple count of 100Hz 
ticks would fill an unsigned 32 bit integer in 497 days, 2 hours, 27 minutes, 
52.96 seconds.
After which it would wrap around to zero.

Interestingly enough Windows 95 had almost exactly the same situation, but 
since they counted at 1000Hz, it triggered after only 49.7 days. The result 
was a little worse too: the machine crashed. Strangely enough this bug was 
not discovered until the year 2000.

-- 
Richard Urwin

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to