Editing 1275: int(pi)

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 14: Line 14:
 
For a number of reasons it is a good programming practice to use {{w|Variable (computer science)|variables}} and {{w|Constant (programming)|constants}} where a value is used in multiple places, however this is not typically used in the case of natural numbers. There are unusual situations where this type of programming is a valid method, however typically for more specific circumstances, and not a certain number being seen as cursed.
 
For a number of reasons it is a good programming practice to use {{w|Variable (computer science)|variables}} and {{w|Constant (programming)|constants}} where a value is used in multiple places, however this is not typically used in the case of natural numbers. There are unusual situations where this type of programming is a valid method, however typically for more specific circumstances, and not a certain number being seen as cursed.
  
βˆ’
In the title text, Randall takes the joke a step further, suggesting the usage of {{w|floor and ceiling functions}}: <code>ceiling(pi)</code> would be pi rounded ''up'' to the next integer, which is {{w|4 (number)|4}}; and <code>floor(pi)</code> is pi rounded ''down'' to the next integer, which is 3. (Note that <code>int(n)</code> and <code>floor(n)</code> have the same value when <code>n</code> is greater than or equal to zero. For values less than zero, <code>int(n)</code> is equal to <code>ceiling(n)</code>.)
+
In the title text, Randall takes the joke a step further, suggesting the usage of {{w|floor and ceiling functions}}: <code>ceiling(pi)</code> would be pi rounded ''up'' to the next integer, which is {{w|4 (number)|4}}; and <code>floor(pi)</code> is pi rounded ''down'' to the next integer, which is 3. (Note that <code>int(n)</code> and <code>floor(n)</code> have the same value when <code>n</code> is greater or equal to zero. For values less than zero, <code>int(n)</code> is equal to <code>ceiling(n)</code>.)
  
 
The joke here plays on the fact that basic rules of programming are confusing and novice programmers are often told to simply not do certain things without any explanation (see [[292: goto]]). This includes, in particular, a general proscription against "{{w|Magic number (programming)#Unnamed numerical constants|magic numbers}}" in the code. Replacing all significant magic numbers with named constants makes programs easier to read, understand and maintain. Randall takes this to an extreme by suggesting that certain numbers could be inherently problematic, but the general idea is perfectly believable.
 
The joke here plays on the fact that basic rules of programming are confusing and novice programmers are often told to simply not do certain things without any explanation (see [[292: goto]]). This includes, in particular, a general proscription against "{{w|Magic number (programming)#Unnamed numerical constants|magic numbers}}" in the code. Replacing all significant magic numbers with named constants makes programs easier to read, understand and maintain. Randall takes this to an extreme by suggesting that certain numbers could be inherently problematic, but the general idea is perfectly believable.

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)