You've likely already guessed that arithmetic functions in MUF have to follow their operands, just as comparison functions do, resulting in yet another jarring clash with The World According To Ms Grundy:
Stack: 2 2 + Stack: 4 pop 2 3.4 * Stack: 6.8 pop 5 3 - Stack: 2 pop 6.5 2.3 div Stack: 2.82609
There's really not a lot else to say about arithmetic! As with many computer languages, numbers can only get so big, after which you get nonsensical results:
Stack: 2.0 Stack: 2 : square -> x x x * ; Stack: 2 square Stack: 4 square Stack: 16 square Stack: 256 square Stack: 65536 square Stack: 4.29497e+09 square Stack: 1.84467e+19 square Stack: Infinity
Obviously, we didn't really reach infinity, we just reached a number larger than MUF knows how to represent.
Be aware that dividing integers (numbers without decimal points) gives the largest integer less than or equal to the real result, while dividing floating point numbers (numbers with decimal points) gives a floating point result:
Stack: 9.0 4.0 div Stack: 2.25 pop 9 4 div Stack: 2
Both types of division are useful, but the results can be puzzling if you get the wrong sort of division for what you intended!
Ms Grundy always told you that you can't divide by zero. What do you think MUF will do if you try? (Hint: If you haven't figured this out by now, the fastest way to decide many questions like this is just to try it. You can't break anything. Honest!)
Go to the first, previous, next, last section, table of contents.