Editing 571: Can't Sleep
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 7: | Line 7: | ||
}} | }} | ||
− | ==Explanation== | + | == Explanation == |
− | [[Cueball]] is in bed and is having trouble sleeping. He tries the old standby of | + | In this comic, [[Cueball]] is in bed and is having trouble sleeping. He tries the old standby of counting sheep as they jump over a fence, but upon reaching 32,767 sheep, the sheep all jump back over the fence and start counting up again from -32,768. This is because when an integral number 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 results in starting over at the least possible number given the storage space. This is not at all unlike a car's odometer. Imagine an odometer with six digits reaching 999999 miles. Upon driving one more mile, the digits will roll back over to 000000. |
− | In this case, the least and greatest possible numbers are -32,768 and 32,767, which implies that | + | In this case, the least and greatest possible numbers are -32,768 and 32,767, which implies that the storage space used would be two bytes. In addition, it's clear that the number is designated as a signed number, meaning that it can be either positive or negative. |
− | + | The image text refers to the 1968 Philip K. Dick science fiction novel ''Do Androids Dream of Electric Sheep?'', which was adapted into the perhaps more widely known Ridley Scott directed 1982 film ''Blade Runner''. The implication is that if we ever do create androids that dream of electric sheep, we should make sure to give them sufficient storage space to store numbers large enough such that an arithmetic overflow will be far less likely to occur, even if they count for a long time. A "long int" consists of four bytes rather than two, so instead of being limited to a range from -32,768 to 32,767 the number will be capable of storing numbers from -2,147,483,648 to 2,147,483,647. "sheepCount" is a possible name for a variable to be used in a computer program. Declaring a variable tells the computer that it should allocate a portion of memory to be associated with the variable name given. For those who might be unfamiliar with common programming practices, "sheepCount" is named using what is commonly referred to as CamelCase, meaning that all words in the name ("sheep" and "count") are pushed together and the first letter of every word after the first is capitalized. This is one of several common approaches to naming variables in computer programming. | |
− | |||
− | The | ||
==Transcript== | ==Transcript== | ||
− | :[Cueball is in bed, presumably trying to sleep. The top of each panel is a thought bubble showing sheep leaping over a fence | + | :[Cueball is in bed, presumably trying to sleep. The top of each panel is a thought bubble showing sheep leaping over a fence.] |
− | :1... 2... | + | :1 ... 2 ... |
− | : | + | :baaa |
− | + | :[Two sheep are jumping from left to right.] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | :[Two sheep are | ||
− | |||
− | |||
+ | :... 1,306 ... 1,307 ... | ||
+ | :baaa | ||
+ | :[Two sheep are jumping from left to right. The would-be sleeper is holding his pillow.] | ||
+ | :... 32,767 ... -32,768 ... | ||
+ | :''baaa baaa baaa baaa baaa'' | ||
+ | :[A whole flock of sheep is jumping over the fence from right to left. The would-be sleeper is sitting up.] | ||
+ | :Sleeper: ? | ||
− | + | :... -32,767 ... -32,766 ... | |
+ | :baaa | ||
+ | :[Two sheep are jumping from left to right. The would-be sleeper is holding his pillow over his head.] | ||
+ | {{Comic discussion}} | ||
[[Category:Comics featuring Cueball]] | [[Category:Comics featuring Cueball]] | ||
− | |||
− |