Lurker News
Hi HN

It also supports percentages, dates and variables.
I've been working on this alone for a few years now, so would love to get some feedback.

Comments (239) 97 threads

Show all comments

Showing thread 37 of 97

brospars4 replies#
There is something wrong with the order of operations. When I type 2+2*2-6 i get -6 which should be 0.
unsafecast1 reply#
It looks like APL order? Right-to-left.
JackFr1 reply#
No. It’s not right to left. It’s just weird:

  3 ^ 1 * 2   6
  3 ^ 1 / 2   1.73205
  3 ^ 1 + 2   5
  3 ^ 1 - 2   1
unsafecast#
Huh.
sneak#
I would think this might be the first unit test one would write for a calculator program.
bdwjn1 reply#
Oh there's more:

9 - 3 ^ 2 = 0
9 -3 ^ 2 = 18 ???
pi = 3.1415926536
2 pi = 5.1415926536 ???
sin(3.1415926536 radians) = -0
sin(pi radians) = Incompatible units ???

wizofaus1 reply#
Seems to assume + if an arithmetic operator is missing?
tonyonodi1 reply#
This is correct, the idea is that you can type things like "6 foot 3 inches" and have it evaluate as an addition. But the example shown above is definitely a problem, I'll try to think of a work around.

Continue this thread — 1 reply

simonz05#
Yep, this should be evaluated as `(- (+ 2 (* 2 2)) 6)`