Dev log
My platform, DANGCSA/DANGXA, now has a specific protocol on how to handle numerics. The processor implementation, the DLU, instantiates a new coprocessor called the DMU, or DANGLING Math Unit, which runs addition, multiplication, and division. n-dimensional tensors are supported, i.e. scalars, vectors, arrays, and above.
The DMU is not implemented like a standard math coprocessor like the x87 would be. It is extremely opinionated as to what it considers a "real" number. For example, irrational and imaginary numbers are not supported at all. I don't like the fact that we're treating some numbers as some abstracts with infinitely many decimal positions. I also don't like that if I have a full pizza and I split it among three friends, each of whom gets an equivalently sized chunk and I store the fraction that represents each chunk as a float, I have to pretend that it's some chunk with different dimensions compared to what it physically is. So then, if we all combine our larger chunks, do we have a larger pizza than what we started with? That doesn't make any sense.
This is why the DMU uses fractions to represent such values. 1/3 is completely finite (in terms of the numbers required to quantify the value precisely) and precisely representable in memory, unlike 0.33... repeating, which would end up as ~0.33 (or a similarly rounded value based on precision, like 0.3333333), which is no longer my pizza chunk. If I relinquish my chunk to a friend, then the friend would have 0.66 parts of the pizza? So, then, how large would the whole pizza be? So the DMU doesn't manufacture quantities that don't physically exist. This also avoids a large category of float precision issues that occur in computing. If a value is not precisely representable, then the DLU will trap. This is taken as seriously as div0 is.
Float is not banned altogether. You may use float if you can represent it exactly. The DMU doesn't use the IEEE-754, so binary float representation is not a problem for floats that terminate. 0.1 or 77.3 or 69.69 can all be stored as bits exactly. If you have a health value of 100.0 and you decide that you will only decrement in steps of 0.1, and after a bit of play time and damage you have 77.3, then that is fully representable and we don't have a problem. But we do have a problem if you try (float)1/3.
For irrational numbers, there is a set of reserved keywords, like pi, which can be used inline. You could have a 15cm radius pizza whose circumference is 30*pi cm, and it would be a valid result. I keep thinking of a way to calculate it exactly while avoiding having to use an irrational number. I am determined to find a way, but for now, this is the best solution available. If you're a math PhD, hit me up, :D.
Thanks for reading,
*DanglingPtr
