News for hackers. Stuff that matters.
Re:2^3^4 - a comparison of math packages by ntkachov on Monday February 06, 2012 @03:20AM (#3556657)
This is exactly why when ever I need to do any sort of math in a program I make sure to put parens around any single operation. Even 2*2+2 gets the treatment because god knows there have been people who screwed that up.
Re:2^3^4 - a comparison of math packages by masklinn on Monday February 06, 2012 @04:14AM (#3556754)
> Even 2x2+2 gets the treatment

2+2x2 I can see (Smalltalk has strict left-to-right evaluation of operators, so it parses as (2+2)x2), but for 2x2+2 to give the "wrong" would require `+` to have a higher precedence than `*`, something I've yet to see (short of abusing haskell to redefine the operators with fucked up precedences)

edit: god fucking dammit HN can't you get any markup right?

Re:2^3^4 - a comparison of math packages by pangram on Monday February 06, 2012 @05:04AM (#3556867)
If I recall correctly, APL executes right to left -- so it would return 8 for 2*2+2.
Re:2^3^4 - a comparison of math packages by masklinn on Monday February 06, 2012 @07:39AM (#3557185)
Neat, I'd forgotten languages could execute RTL as well.
Re:2^3^4 - a comparison of math packages by ntkachov on Monday February 06, 2012 @04:18AM (#3556764)
My point exactly. Had I had to do something in Smalltalk and not known that, that would have been a fun bug to find had I decided to be frisky and write it as 2+2*2.