1275: "int(pi)"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

asdfzxc
Posts: 60
Joined: Mon Jun 08, 2009 7:04 pm UTC

1275: "int(pi)"

Postby asdfzxc » Wed Oct 09, 2013 4:03 am UTC

Image

Alt-text: "If replacing all the '3's doesn't fix your code, remove the 4s, too, with 'ceiling(pi) / floor(pi) * pi * r^floor(pi)'. Mmm, floor pie."

I'll have to remember that one.

n079614
Posts: 11
Joined: Mon Feb 07, 2011 9:26 am UTC

Re: 1275: "int(pi)"

Postby n079614 » Wed Oct 09, 2013 4:14 am UTC

Why do I get the feeling that this whole thing was to set up the alt-text pie joke?

Lordy! Am I becoming cynical?

User avatar
Quicksilver
Posts: 437
Joined: Wed Apr 29, 2009 6:21 am UTC

Re: 1275: "int(pi)"

Postby Quicksilver » Wed Oct 09, 2013 4:17 am UTC

Pi is exactly 3?

User avatar
rhomboidal
Posts: 766
Joined: Wed Jun 15, 2011 5:25 pm UTC
Contact:

Re: 1275: "int(pi)"

Postby rhomboidal » Wed Oct 09, 2013 4:18 am UTC

I knew "3" was the bad apple in "13". "1" is infallible and infinitely perfectly self-divisible.

Demki
Posts: 194
Joined: Fri Nov 30, 2012 9:29 pm UTC

Re: 1275: "int(pi)"

Postby Demki » Wed Oct 09, 2013 4:24 am UTC

Quicksilver wrote:Pi is exactly 3?

No, int(Pi) is exactly 3. Same for floor(Pi).
This comic gave me a "meh" moment.

User avatar
phlip
Restorer of Worlds
Posts: 7545
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: 1275: "int(pi)"

Postby phlip » Wed Oct 09, 2013 4:30 am UTC

The fraction looks relatively clean, in mathematical notation:

Image

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
ConMan
Shepherd's Pie?
Posts: 1636
Joined: Tue Jan 01, 2008 11:56 am UTC
Location: Beacon Alpha

Re: 1275: "int(pi)"

Postby ConMan » Wed Oct 09, 2013 4:33 am UTC

Quicksilver wrote:Pi is exactly 3?

While there are some variations between programming languages, what Randall's doing here is referring to three specific functions:
floor(x) gives the highest integer that is less than or equal to x. So floor(3) = floor(3.01) = floor(3.8) = floor(pi) = 3.
ceiling(x) gives the lowest integer that is greater than or equal to x. So ceiling(4) = ceiling(3.01) = ceiling(3.8) = ceiling(pi) = 4.
int(x) gives the nearest integer to x, i.e. it gives x rounded to the nearest 1. So int(3) = int(3.01) = int(2.8) = int(pi) = 3.

In other words, he's providing a way to calculate the volume of a sphere ostensibly in terms of pi and the radius of the sphere.
pollywog wrote:
Wikihow wrote:* Smile a lot! Give a gay girl a knowing "Hey, I'm a lesbian too!" smile.
I want to learn this smile, perfect it, and then go around smiling at lesbians and freaking them out.

User avatar
phlip
Restorer of Worlds
Posts: 7545
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: 1275: "int(pi)"

Postby phlip » Wed Oct 09, 2013 4:43 am UTC

ConMan wrote:int(x) gives the nearest integer to x, i.e. it gives x rounded to the nearest 1. So int(3) = int(3.01) = int(2.8) = int(pi) = 3.

In most programming languages I've come across, int() rounds towards zero (ie the same as floor() for positive numbers and ceil() for negative numbers... simply truncating the number at the decimal point). Sometimes it rounds down (ie same as floor()) but that's less common. There aren't that many that it's a round-to-nearest operation... usually there's a separate round() function for that, or failing that, floor(x + 0.5).

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

trwrt
Posts: 1
Joined: Wed Oct 09, 2013 4:47 am UTC

Re: 1275: "int(pi)"

Postby trwrt » Wed Oct 09, 2013 4:52 am UTC

This code doesn't work correctly. Because of the parens around (4/int(pi)) the expression will be evaluated as an integer, yielding 1 instead of 1.3333... Only after the division does the result get promoted to float for the rest of the operations. If it read 4/int(pi)*pi*r^int(pi) then it would work because everything would get promoted to float beforehand.

User avatar
phlip
Restorer of Worlds
Posts: 7545
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: 1275: "int(pi)"

Postby phlip » Wed Oct 09, 2013 4:59 am UTC

trwrt wrote:This code doesn't work correctly. Because of the parens around (4/int(pi)) the expression will be evaluated as an integer, yielding 1 instead of 1.3333... Only after the division does the result get promoted to float for the rest of the operations. If it read 4/int(pi)*pi*r^int(pi) then it would work because everything would get promoted to float beforehand.

Well, that depends on the language in question. Some languages will treat the division of two ints as an int division, others as a float division (and have some other syntax for performing an int division). If you're going to assume we're using a specific language, you may as well complain that "^" is bitwise XOR instead of the power function, or that it should be "(int)x" instead of "int(x)" also the constant is called "M_PI" and "func(x) = expr" isn't the valid C function declaration syntax.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
cjmcjmcjmcjm
Posts: 1158
Joined: Tue Jan 05, 2010 5:15 am UTC
Location: Anywhere the internet is strong

Re: 1275: "int(pi)"

Postby cjmcjmcjmcjm » Wed Oct 09, 2013 5:22 am UTC

Floor pi is best pi. (now I'm hungry)

Half-Life 2: Episode Pi
frezik wrote:Anti-photons move at the speed of dark

DemonDeluxe wrote:Paying to have laws written that allow you to do what you want, is a lot cheaper than paying off the judge every time you want to get away with something shady.

SomeoneSomewhere
Posts: 34
Joined: Tue Jul 02, 2013 4:51 am UTC

Re: 1275: "int(pi)"

Postby SomeoneSomewhere » Wed Oct 09, 2013 5:23 am UTC

Just don't use PHP: 4 ^ 3 returns 7 (it's bitwise XOR).

I think int(x) is usually truncate or round toward zero; that is 3.14 => 3, 5.6 => 5, -2.2 => -2. You get the picture.

Round is usually separate.

(edited to be clearer)

zukenft
Posts: 44
Joined: Mon Dec 20, 2010 11:34 am UTC

Re: 1275: "int(pi)"

Postby zukenft » Wed Oct 09, 2013 5:38 am UTC

eh, having a 3 in your code is fine. a 4 though, you know what they say : four means death.

User avatar
azule
Saved
Posts: 2132
Joined: Mon Jul 26, 2010 9:45 pm UTC
Location: The land of the Golden Puppies and Rainbows

Re: 1275: "int(pi)"

Postby azule » Wed Oct 09, 2013 5:49 am UTC

Hah, I love it. I actually got one of these programming jokes on my own. Ok, it's actually math, right? But close enough. :)
Image

If you read this sig, post about one arbitrary thing you did today.

I celebrate up to six arbitrary things before breakfast.
Time does drag on and on and contain spoilers. Be aware of memes.

User avatar
keithl
Posts: 612
Joined: Mon Aug 01, 2011 3:46 pm UTC

Re: 1275: "int(pi)"

Postby keithl » Wed Oct 09, 2013 5:54 am UTC

Stop the irrationality! Vote no on ballot measure π!

User avatar
Eternal Density
Posts: 5496
Joined: Thu Oct 02, 2008 12:37 am UTC
Contact:

Re: 1275: "int(pi)"

Postby Eternal Density » Wed Oct 09, 2013 6:22 am UTC

I rewrote all of Sandcastle Builder's code to conform to this.
So now I have lines like

Code: Select all

Molpy.Boosts['Double or Nothing'].department=1*(Math.floor(Math.random()*Math.floor(Math.PI))==0);

or

Code: Select all

var nBuy = Math.pow(Math.ceil(Math.PI),Molpy.options.castlemultibuy);

and I'm not risking it with numbers close to int(pi):

Code: Select all

bonus+=Molpy.SandToolsById[i].amount*Math.pow(Math.floor(Math.PI)+.5,i+1);

or fractions of it:

Code: Select all

var amount = Math.pow(1+Math.ceil(Math.PI)/10,Math.max(0,(Molpy.SandTools['Bag'].amount-Molpy.npbDoubleThreshhold)/2))-1;

or strings:

Code: Select all

,"The Lord of the Bags "+Math.floor(Math.PI)+": The Return of La Petite"
,"Half-Bag "+Math.floor(Math.PI)+" Confirmed!"

or combinations of the above:

Code: Select all

   new Molpy.Boost({name:'Embaggening',desc:'Each Cuegan after the 14th gives a 2% boost to the sand dig rate of Bags',
      sand:Math.floor(Math.PI)+'.5M',castles:'23K',icon:'embaggening'});

or numbers users might see:

Code: Select all

      if(number==Math.floor(Math.PI))return 'Math.floor(Math.PI)';
      if(number==Math.ceil(Math.PI))return 'Math.ceil(Math.PI)';


This delayed the release of version 1.81. I hope GLR is happy.
Play the game of Time! castle.chirpingmustard.com Hotdog Vending Supplier But what is this?
In the Marvel vs. DC film-making war, we're all winners.

Pi is exactly three
Posts: 43
Joined: Fri Apr 17, 2009 9:33 pm UTC
Location: London, United Kingdom

Re: 1275: "int(pi)"

Postby Pi is exactly three » Wed Oct 09, 2013 7:32 am UTC

Well, I wish I had known of this curse BEFORE I chose my forum username...
"We are the weirdos, Mister!"
--Fairuza Balk, The Craft

I have travelled from 1955 to be a member of the unofficial board Council of Elders. Phear M3

User avatar
Arancaytar
Posts: 1642
Joined: Thu Mar 15, 2007 12:54 am UTC
Location: 52.44°N, 13.55°E
Contact:

Re: 1275: "int(pi)"

Postby Arancaytar » Wed Oct 09, 2013 8:13 am UTC

Remember, you can generate EVERY natural number by a finite expression of the form ceil(pi)+...+ceil(pi)-floor(pi)-...-floor(pi)! :D
"You cannot dual-wield the sharks. One is enough." -Our DM.
Image

User avatar
orthogon
Posts: 2763
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1275: "int(pi)"

Postby orthogon » Wed Oct 09, 2013 8:25 am UTC

This reminded me of the techniques used on the ZX81 and ZX Spectrum, where "1" was often replaced by PI/PI and "0" by PI-PI.

The BASIC programs were tokenized on entry and stored in tokenized form. Numeric literals were stored as an escape byte followed by four bytes of floating point. Keywords were a single byte in the high ASCII range; these didn't even need to be scanned since they were entered with a single keypress. It was beautiful. The upshot was that a "1" took up 5 bytes, whereas PI/PI only took three. Bear in mind that you only had 1KB of memory to fit your program and data.
xtifr wrote:... and orthogon merely sounds undecided.

User avatar
Monika
Welcoming Aarvark
Posts: 3652
Joined: Mon Aug 18, 2008 8:03 am UTC
Location: Germany, near Heidelberg
Contact:

Re: 1275: "int(pi)"

Postby Monika » Wed Oct 09, 2013 9:44 am UTC

SomeoneSomewhere wrote:Just don't use PHP: 4 ^ 3 returns 7 (it's bitwise XOR).

Is there even any language where ^ (if it exists at all) does not mean XOR and does mean "to the power of"?

orthogon wrote:This reminded me of the techniques used on the ZX81 and ZX Spectrum, where "1" was often replaced by PI/PI and "0" by PI-PI.

The BASIC programs were tokenized on entry and stored in tokenized form. Numeric literals were stored as an escape byte followed by four bytes of floating point. Keywords were a single byte in the high ASCII range; these didn't even need to be scanned since they were entered with a single keypress. It was beautiful. The upshot was that a "1" took up 5 bytes, whereas PI/PI only took three. Bear in mind that you only had 1KB of memory to fit your program and data.

Wow :D
#xkcd-q on irc.foonetic.net - the LGBTIQQA support channel
Please donate to help these people e.g. Ragna needs these items and Frances needs money for food

Choonster
Posts: 2
Joined: Sat Sep 28, 2013 5:41 am UTC

Re: 1275: "int(pi)"

Postby Choonster » Wed Oct 09, 2013 10:05 am UTC

Monika wrote:
SomeoneSomewhere wrote:Just don't use PHP: 4 ^ 3 returns 7 (it's bitwise XOR).

Is there even any language where ^ (if it exists at all) does not mean XOR and does mean "to the power of"


Lua [lua.org] (and MoonScript [moonscript.org], which compiles into Lua) uses ^ for exponent instead of XOR.

Eoink
Posts: 83
Joined: Fri Nov 30, 2012 12:33 pm UTC

Re: 1275: "int(pi)"

Postby Eoink » Wed Oct 09, 2013 10:29 am UTC

orthogon wrote:This reminded me of the techniques used on the ZX81 and ZX Spectrum, where "1" was often replaced by PI/PI and "0" by PI-PI.

The BASIC programs were tokenized on entry and stored in tokenized form. Numeric literals were stored as an escape byte followed by four bytes of floating point. Keywords were a single byte in the high ASCII range; these didn't even need to be scanned since they were entered with a single keypress. It was beautiful. The upshot was that a "1" took up 5 bytes, whereas PI/PI only took three. Bear in mind that you only had 1KB of memory to fit your program and data.


Thanks for the memory, I'd completely forgotten that. Ahh, the good old days, if you tell that to kids today they won't believe you. (And in defence of the Speccie, it did come with 16k of RAM as basic, it was the ZX81 and the earlier ZX80 which had the 1k RAM.)

User avatar
phlip
Restorer of Worlds
Posts: 7545
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: 1275: "int(pi)"

Postby phlip » Wed Oct 09, 2013 10:41 am UTC

Choonster wrote:
Monika wrote:Is there even any language where ^ (if it exists at all) does not mean XOR and does mean "to the power of"

Lua [lua.org] (and MoonScript [moonscript.org], which compiles into Lua) uses ^ for exponent instead of XOR.

Haskell and VB both also have ^ as a power-of function as well. Haskell also has ** as a different power-of function... because Haskell is like that. (x^n is integer exponentiation, defined for anything that supports multiplication, to the power of a natural number... x**y is floating point exponentiation, only defined for floats.)

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

Randomizer
Posts: 284
Joined: Fri Feb 25, 2011 8:23 am UTC
Location: My walls are full of hungry wolves.
Contact:

Re: 1275: "int(pi)"

Postby Randomizer » Wed Oct 09, 2013 10:52 am UTC

Ok, I could kinda see if this was a "the program isn't working and for some dumb reason doing X seemingly irrelevant thing fixes it" joke, but... I'm just not seeing what the "the number 3 is cursed" thing is in reference to. Things like pi/pi instead of 1 being used to save memory, I guess it could be related to this, but still that doesn't quite seem to fit.

Anyone have any idea what that's about?
Belial wrote:I'm all outraged out. Call me when the violent rebellion starts.

User avatar
PM 2Ring
Posts: 3621
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: 1275: "int(pi)"

Postby PM 2Ring » Wed Oct 09, 2013 10:57 am UTC

Monika wrote:Is there even any language where ^ (if it exists at all) does not mean XOR and does mean "to the power of"?

Also bc, a programmable arbitrary-precision calculator found in many Linux distros. However, the power must be an integer; if you want arbitrary powers, you need to use logs.

Gargravarr
Posts: 74
Joined: Mon Dec 21, 2009 8:34 am UTC

Re: 1275: "int(pi)"

Postby Gargravarr » Wed Oct 09, 2013 11:13 am UTC

The PI rule of project estimation: Analyze the project and calculate a reasonable estimate of how much time it should take. Then multiply with PI.

User avatar
orthogon
Posts: 2763
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1275: "int(pi)"

Postby orthogon » Wed Oct 09, 2013 12:38 pm UTC

MATLAB and Octave use ^ for exponentiation.

Arancaytar wrote:Remember, you can generate EVERY natural number by a finite expression of the form ceil(pi)+...+ceil(pi)-floor(pi)-...-floor(pi)! :D

I was also reminded of a problem set by Chris Maslanka in The Guardian. You have to make all the integers from 1 to 100 using five 5's, e.g.:

1=(5+5)/5-5/5
2=(5+5)/5+5-5
...
100=5x5x5-5x5

I worked on it for a while with a colleague on a business trip. We did pretty well but ran out of time/ideas before we got them all. Some thoughts spoilered in case you want to have a go:
Spoiler:
To start with you are looking for ways to "use up" unneeded 5's (+5-5), but in other regions you have to make each 5 work really hard for you. 5! proved quite useful; I particularly remember using 5!/5 a lot. Only some time later did I get the idea of using the "floor" and "ceiling" operators; applying these to sqrt(5) gives you 2 and 3 for the price of one 5. This seemed too much like cheating and I couldn't decide whether "floor" and "ceiling" are well enough known operators to be allowed.


ETA:
Gargravarr wrote:The PI rule of project estimation: Analyze the project and calculate a reasonable estimate of how much time it should take. Then multiply with PI.

That's way too optimistic. The one I heard was "double it and move to the next larger unit of time", e.g. 3 days -> 6 weeks, 2 months->4 years, etc.
xtifr wrote:... and orthogon merely sounds undecided.

brenok
Needs Directions
Posts: 507
Joined: Mon Oct 17, 2011 5:35 pm UTC
Location: Brazil

Re: 1275: "int(pi)"

Postby brenok » Wed Oct 09, 2013 12:54 pm UTC

orthogon wrote:
Gargravarr wrote:The PI rule of project estimation: Analyze the project and calculate a reasonable estimate of how much time it should take. Then multiply with PI.

That's way too optimistic. The one I heard was "double it and move to the next larger unit of time", e.g. 3 days -> 6 weeks, 2 months->4 years, etc.

1 year -> 2 centuries? Or two decades?

User avatar
Zassounotsukushi
Posts: 76
Joined: Wed Oct 26, 2011 8:38 pm UTC
Contact:

Re: 1275: "int(pi)"

Postby Zassounotsukushi » Wed Oct 09, 2013 1:01 pm UTC

trwrt wrote:This code doesn't work correctly. Because of the parens around (4/int(pi)) the expression will be evaluated as an integer, yielding 1 instead of 1.3333... Only after the division does the result get promoted to float for the rest of the operations. If it read 4/int(pi)*pi*r^int(pi) then it would work because everything would get promoted to float beforehand.


That was my thought. While there are programs that will do (4/3) "correctly", as in the floating point math, I thought that integer division was fairly common. I would think that most real languages would return 1, as you say. If you're using something that's mathematics-oriented, probably not, but the use of ceiling() and floor() makes me think that this is intended to be relatively low-level, and thus not work right.

User avatar
orthogon
Posts: 2763
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1275: "int(pi)"

Postby orthogon » Wed Oct 09, 2013 1:01 pm UTC

brenok wrote:
orthogon wrote:
Gargravarr wrote:The PI rule of project estimation: Analyze the project and calculate a reasonable estimate of how much time it should take. Then multiply with PI.

That's way too optimistic. The one I heard was "double it and move to the next larger unit of time", e.g. 3 days -> 6 weeks, 2 months->4 years, etc.

1 year -> 2 centuries? Or two decades?

I guess 1 year -> The project will be cancelled next month.
xtifr wrote:... and orthogon merely sounds undecided.

User avatar
drachefly
Posts: 187
Joined: Thu Apr 23, 2009 3:25 pm UTC

Re: 1275: "int(pi)"

Postby drachefly » Wed Oct 09, 2013 1:14 pm UTC

orthogon wrote:This reminded me of the techniques used on the ZX81 and ZX Spectrum...


I can't quite decide whether that makes this better or worse.

Mike Rore
Posts: 19
Joined: Wed Dec 05, 2012 4:18 pm UTC

Re: 1275: "int(pi)"

Postby Mike Rore » Wed Oct 09, 2013 1:33 pm UTC

The number three is lava!

User avatar
PM 2Ring
Posts: 3621
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: 1275: "int(pi)"

Postby PM 2Ring » Wed Oct 09, 2013 1:39 pm UTC

orthogon wrote:I was also reminded of a problem set by Chris Maslanka in The Guardian. You have to make all the integers from 1 to 100 using five 5's

The earlier form of this problem (going back to the late 19th century) uses four fours.
The first printed occurrence of this activity is in "Mathematical Recreations and Essays" by W. W. Rouse Ball published in 1892. In this book it is described as a "traditional recreation".

In his discussion of the problem Ball calls it "An arithmetical amusement, said to have been first propounded in 1881, ...." . This date aligns with the appearance of the problem in Knowledge, An Illustrated Magazine of Science, (Dec 30, 1881) edited by Richard A. Proctor, the English astronomer who is remembered for one of the earliest maps of Mars.

I'm pretty sure that I first heard of the four fours puzzle in a Martin Gardner column.

ctdonath
Posts: 198
Joined: Wed Feb 08, 2012 2:40 pm UTC

Re: 1275: "int(pi)"

Postby ctdonath » Wed Oct 09, 2013 1:42 pm UTC

orthogon wrote:This reminded me of the techniques used on the ZX81 and ZX Spectrum, where "1" was often replaced by PI/PI and "0" by PI-PI.

Oh, NOW someone tells me, some 30 years after I needed it. :D

Trying to cram programs AND operating system AND video memory into 1KB meant I NEEDED those extra bytes.

I might just have to dig that l'il beast out and try. Plugging a ZX-80 into an HDTV alone might be quite satisfying...

User avatar
pdg
Posts: 78
Joined: Wed Mar 27, 2013 6:51 pm UTC
Location: Salem, Virginia
Contact:

Re: 1275: "int(pi)"

Postby pdg » Wed Oct 09, 2013 2:11 pm UTC

orthogon wrote:This reminded me of the techniques used on the ZX81 and ZX Spectrum, where "1" was often replaced by PI/PI and "0" by PI-PI.

The BASIC programs were tokenized on entry and stored in tokenized form. Numeric literals were stored as an escape byte followed by four bytes of floating point. Keywords were a single byte in the high ASCII range; these didn't even need to be scanned since they were entered with a single keypress. It was beautiful. The upshot was that a "1" took up 5 bytes, whereas PI/PI only took three. Bear in mind that you only had 1KB of memory to fit your program and data.


I thought of that when I saw this comic, too.

On the Spectrum with 16k or more typically 48k of RAM it wasn't necessary most of the time (I certainly never came close to filling 48k), but it cropped up in the loaders of very large programs like games where the machine code was crammed into RAM so tightly that it left very little space in the BASIC area for the loader to fit.

I could see it on the unexpanded ZX81 though, where every single byte could make a difference. Now there was a system that knew how to use minimal memory. The way the screen contents were stored was particularly ingenious.
We can't go back.
We don't understand everything yet.

User avatar
orthogon
Posts: 2763
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1275: "int(pi)"

Postby orthogon » Wed Oct 09, 2013 2:19 pm UTC

PM 2Ring wrote:
orthogon wrote:I was also reminded of a problem set by Chris Maslanka in The Guardian. You have to make all the integers from 1 to 100 using five 5's

The earlier form of this problem (going back to the late 19th century) uses four fours.

Ah, so it was a twist on an old puzzle.
Spoiler:
The gamma function would have been useful. We could have had 5!/5 using only one 5.

Glad to see there are a few Sinclair BASIC old-timers on here. I had a 48K Spectrum and I agree that the PI-baking wasn't really necessary for that - I think I saw it in printed listings in old Sinclair User mags and it made a lasting impression on me (and, I fear, my coding style) ever after.
xtifr wrote:... and orthogon merely sounds undecided.

cheeseheadtotherescue
Posts: 11
Joined: Wed Jun 03, 2009 5:18 pm UTC

Re: 1275: "int(pi)"

Postby cheeseheadtotherescue » Wed Oct 09, 2013 2:25 pm UTC

!+[]+!+[]+!+[] is 3 in javascript. Also, Astronomers often take pi to be 3 (or even sometimes 1) and pi^2 to be 10 when dealing with large numbers (the kind where you want the order of magnitude to be within an order of magnitude (wrap you're head around that!))

User avatar
cellocgw
Posts: 1784
Joined: Sat Jun 21, 2008 7:40 pm UTC

Re: 1275: "int(pi)"

Postby cellocgw » Wed Oct 09, 2013 2:31 pm UTC

Monika wrote:Is there even any language where ^ (if it exists at all) does not mean XOR and does mean "to the power of"?


Seriously? All {for sufficiently architected values of "all"} higher-level languages use '^' for exponentiation. R, MatLab, and IDL are floor(pi) such examples.

There's this thing called "DWIM" (do what I mean) which, when well implemented, makes programming far faster and easier. The more you have to use non-intuitive methods and characters, the slower your work will be. And further, the harder it'll be for anyone not well-versed in your choice of programming language to understand your code.
https://app.box.com/witthoftresume
Former OTTer
Vote cellocgw for President 2020. #ScienceintheWhiteHouse http://cellocgw.wordpress.com
"The Planck length is 3.81779e-33 picas." -- keithl
" Earth weighs almost exactly π milliJupiters" -- what-if #146, note 7

User avatar
San Fran Sam
Posts: 228
Joined: Tue Nov 15, 2011 5:54 pm UTC

Re: 1275: "int(pi)"

Postby San Fran Sam » Wed Oct 09, 2013 3:21 pm UTC

Would any of those pi be of the pumpkin variety?

smileyy
Posts: 2
Joined: Wed Aug 28, 2013 6:42 pm UTC

Re: 1275: "int(pi)"

Postby smileyy » Wed Oct 09, 2013 3:22 pm UTC

This expression is really slow on my computer, because it wants to calculate the last digit of pi before rounding. Does anyone know a way to optimize this?


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: Google Feedfetcher and 102 guests