@xkcdexplained The Big Caption

Toby, Dave & Ian Explain XKCD

There is a graph. On the X axis is sex, on the Y is computer.

April 20, 2009 at 12:00am
home
A man is laying in bed, following the time-honored anecdotal strategy of counting sheep to get to sleep. It seems he is having some difficulty, because he begins to count thousands and thousands of sheep. Continuing to count, he suddenly finds himself counting negative numbers. Frustrated, he adjusts his pillow and continues to count negative sheep.
The particular numbers are a reference to the “signed 16-byte overflow” limit. This number appears frequently in programming, particularly in older games and embedded systems which used 16-bit values to conserve memory.  The “overflow” or transition from positive to negative numbers happens when the leftmost bit of a signed number is changed from 0 to 1 because of an carry. This is a well understood phenomenon but still serves as a “gotcha” for many novice programmers. Most programmers can relate to a time when they ran afoul of this behavior in their novice stage, which is presumably what the author was hoping to humorously connect with in his audience.
A simple C-program that demonstrates and explains integer overflow is provided here.

A man is laying in bed, following the time-honored anecdotal strategy of counting sheep to get to sleep. It seems he is having some difficulty, because he begins to count thousands and thousands of sheep. Continuing to count, he suddenly finds himself counting negative numbers. Frustrated, he adjusts his pillow and continues to count negative sheep.

The particular numbers are a reference to the “signed 16-byte overflow” limit. This number appears frequently in programming, particularly in older games and embedded systems which used 16-bit values to conserve memory.  The “overflow” or transition from positive to negative numbers happens when the leftmost bit of a signed number is changed from 0 to 1 because of an carry. This is a well understood phenomenon but still serves as a “gotcha” for many novice programmers. Most programmers can relate to a time when they ran afoul of this behavior in their novice stage, which is presumably what the author was hoping to humorously connect with in his audience.

A simple C-program that demonstrates and explains integer overflow is provided here.

Notes

  1. xkcdexplained posted this