Editing 571: Can't Sleep

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 10: Line 10:
 
[[Cueball]] is in bed and is having trouble sleeping. He tries the old standby of {{w|counting sheep}} as they jump over a fence, but upon reaching 32,767 sheep, 65535 sheep jump back over the fence and start counting up again from -32,768. This is a reference to an integer overflow, when an increasing amount (sheep in this case) suddenly overflows and shows up as a negative value. This is because when a whole number or integer is represented in a digital form, such as on a computer, the number's range is limited by the amount of space used to store it. When the greatest possible number given the storage space is exceeded, an arithmetic overflow occurs, which may result (depending on the used language among other things) in starting over at the least possible number given the storage space, similar to a car's odometer. Imagine an odometer with six digits reaching 999999. Upon driving one more mile or km, the digits will roll back over to 000000. Causing or failing to prevent integer overflow is a common mistake by programmers that may have software security consequences. Some languages like C/C++ even leaves the signed integer overflow ''undefined behavior'', it may or may not wrap to the beginning, the instruction can be ignored or may cause the software to crash.
 
[[Cueball]] is in bed and is having trouble sleeping. He tries the old standby of {{w|counting sheep}} as they jump over a fence, but upon reaching 32,767 sheep, 65535 sheep jump back over the fence and start counting up again from -32,768. This is a reference to an integer overflow, when an increasing amount (sheep in this case) suddenly overflows and shows up as a negative value. This is because when a whole number or integer is represented in a digital form, such as on a computer, the number's range is limited by the amount of space used to store it. When the greatest possible number given the storage space is exceeded, an arithmetic overflow occurs, which may result (depending on the used language among other things) in starting over at the least possible number given the storage space, similar to a car's odometer. Imagine an odometer with six digits reaching 999999. Upon driving one more mile or km, the digits will roll back over to 000000. Causing or failing to prevent integer overflow is a common mistake by programmers that may have software security consequences. Some languages like C/C++ even leaves the signed integer overflow ''undefined behavior'', it may or may not wrap to the beginning, the instruction can be ignored or may cause the software to crash.
  
βˆ’
In this case, the least and greatest possible numbers are -32,768 and 32,767, which implies that Cueball's brain would only be 16-bit. In addition, it's clear that the number is designated as a signed number, meaning that it can be either positive or negative.
+
In this case, the least and greatest possible numbers are -32,768 and 32,767, which implies that Cueball's brain would only use 16 bits. In addition, it's clear that the number is designated as a signed number, meaning that it can be either positive or negative.
  
 
However, even if Cueball had this limitation, it would never actually pose a problem. By 32,767 sheep, at a rate of one sheep per second, Cueball has been counting for 9.101 hours (or about 9 hours 6 minutes). This would signify that he has extreme insomnia and probably needs treatment, and also that he has spent the entire night counting, and therefore would just get up and start the day rather than count sheep all over again from -32,768.
 
However, even if Cueball had this limitation, it would never actually pose a problem. By 32,767 sheep, at a rate of one sheep per second, Cueball has been counting for 9.101 hours (or about 9 hours 6 minutes). This would signify that he has extreme insomnia and probably needs treatment, and also that he has spent the entire night counting, and therefore would just get up and start the day rather than count sheep all over again from -32,768.

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)