Negative integers and real numbers?

In addition of the signed math library mentioned above, which uses lists like [- 729] to represent signed numbers, I thought of another, likely more performant approach. (Although it should not matter a lot).

The idea would be to choose a arbitrary number as a zero, for example 16383 divided by two, which is 8191. Any number below that would be “negative”, and any above positive. (But of course it divides the absolute range by 2.)

For decimal numbers, if you only need numbers between -1 and 1 with 3 decimal places, you could use fixed-point math. So 1000 would represent 1.000, 729 would represent 0.729, and so on. And you could combine that with any method above to get negative numbers.

But I’m just throwing ideas, I haven’t implemented any of those, sorry.


Finally, and while it’s not strictly related, I’ve written some code to be able to use reverse Polish notation in Dialog, if you want something more compact to write than the built-in rules.

3 Likes