Submitted by twovests in killallgames
I'm ANGERY and I have been for EVER SINCE I LEARNED ABOUT FLOATING POINTS
I'm going to assume you're familiar with floating points and their limitations. If you aren't, this video by Pannen explains them perfectly and belongs in every computer science curriculum for the rest of forever:
https://www.youtube.com/watch?v=9hdFG2GcNuA
I'm going to be short about my ANGERY.
If you walk far enough in Minecraft, floating point arithmetic starts to make movement wonky, far before you hit the far lands (int bounds) This doesn't bode a problem for most games. But they still suck!
Floating points suck because:
- They represent real limitations for games (not really, but let's pretend)
- They're more computationally expensive (also not a big deal at all)
- They're susceptible to flaws (different hardware might do different fast float maths - bad for speedruns, maybe? but also not a big deal at all)
- They're not even the right tool!
The right tool is the rarely-supported "fixed point" number.
In an ideal world, a fixed point number would work a lot like a floating point, except the precision is constant. Computationally, they'd work just the same as integers, with a little bit of overhead when using them in functions or with other datatypes. In terms of programming, working with them would be similar to working with floating points.
I had a long ramble on 1. The (small) problems with supporting them natively and 2. Why it sucks to work with them without native support. But I deleted it because it was long. Basically, support can and should be added to languages like C, C++, etc.! Else it'll be just Awful to work with them.
Other places we see floating points where fixed points could work just as well:
-
Normals (you're using a floating point for a number bounded -1 to 1! what a waste of floating points!)
-
Speed (and acceleration and any other values dealing with movement)
-
Angles/vector math (angles are bounded 0 to 360, or o to 2pi!! So many opportunities to take advantage of fixed point math for angles.)
-
Anything dealing with percentages (likely bounded 0 to 1, or 0 to 100.)
Places where you do see fixed point arithmetic IRL:
-
Dealing with money (in terms of cents or fractions of a cent.)
-
The first DOOM, apparently
-
Most digital encoding of analog signals, sort of? (See: Music encoding)
-
See more here: https://en.wikipedia.org/wiki/Fixed-point_arithmetic
In the end none of this matters at all, but, i want to use fixed point arithmetics;;;
voxpoplar wrote
All numbers in PICO-8 are fixed precision. Yet another reason all games should be made in PICO-8.