Talk:1275: int(pi)

Explain xkcd: It's 'cause you're dumb.
Revision as of 10:43, 9 October 2013 by 81.138.95.57 (talk)
Jump to: navigation, search

Well, I get the int(Pi) thing, but what's with avoiding 3's? 95.35.58.168 05:10, 9 October 2013 (UTC)

What is "floor pie"? --JakubNarebski (talk) 05:31, 9 October 2013 (UTC)

I thought this was a reference to Bleem and reminds me of comic 899. Saibot84 06:17, 9 October 2013 (UTC)

Prudent mathematicians just refer to it as "The Scottish Number". Dr Pepper (talk) 06:58, 9 October 2013 (UTC) Dr Pepper

I can give you one rational reason for spelling out things like INT(PI) in programming. Back in the ancient times, there was a piece of electronics dubbed then a personal computer with an NSA code name of ZXSPECTRUM. It had a built-in interpreter of the ancient language codenamed BASIC. Memory was very precious in those times, every single byte counted. The creators of the interpreter did a (somewhat) clever thing - all keywords of this particular dialect of the BASIC language were stored in memory as single-byte codes, and were only spelled out by text display routines. On the other hand, CPU cycles were precious, too, so they did another (not so) clever thing by storing number constants (like the cursed number mentioned above) twofold - both in an ASCII decimal form for display purposes and in a 6-byte internal binary form for computing purposes. Therefore each number occupied the space of six bytes plus the number of digits (or other characters like sign, decimal point, etc.) BASIC hackers exploited this (mis)features to save a few bytes on some commonly-used constants by saying INT PI (parentheses were not needed), NOT PI (to get 0) or SGN PI (to get 1), thus using only 2 bytes of memory instead of 7 if the numbers were used directly. Another trick to use with larger numbers was VAL "12345", which saved 3 bytes for each number spelled this way (number of digits plus three bytes for the VAL keyword and two quote marks instead of number of digits plus six bytes of internal representation). 89.174.214.74 08:43, 9 October 2013 (UTC)

Actually the internal binary form of the number was 5 bytes, but there was a special prefix byte used for two purposes, a) when listing the program the text display routines would simply skip the six bytes b) when a digit character was encountered at run time, the prefix byte was located instead of parsing the number again. It was even possible to patch the source code to replace all the digits with a single decimal point because the syntax wasn't checked at runtime. Also the trick was originally used with the ZX81 as it was slower and had less memory. I don't think the sign was stored with the number though, as that would have caused confusion with the unary minus operator. (All of the space-saving tricks mentioned above would slow the program down, of course. Even PI had to be calculated as internally the ZX81/Spectrum only knew the value of π/2.) --81.138.95.57 10:43, 9 October 2013 (UTC)

I suspect in many languages 4/INT(pi) is 1 (as it does integer division) 193.34.186.165 08:51, 9 October 2013 (UTC)