Yet another alternative to floating-point numbers
wordsandbuttons.online
wordsandbuttons.online
So what you do is either keep track of the precision manually in your call stack, but then you get the bright idea to pass it as data along with your integer. And you don't need 64 bits of precision because that's a lot, you can live with 52 and use the extra bits to hold your exponent. And lo and behold you've discovered floating point.
As carlmr mentioned, the Ada language has built-in support for fixed-point arithmetic types.
If you look at ADA, a language made for safety critical systems programming, it has even a very nice abstraction for these:
https://www.adaic.org/resources/add_content/standards/05rm/h...
If your calculations require you be able to square any of that unit, the largest you can go without running out of range in your intermediate calculations is cut to ... 4 meters. God help you if you need a higher power than 2.
Same deal for taking the product of several numbers for an area or volume.
Working in fixed point has its benefits and it has its costs. Not so unlike manual memory management, but automatic memory management doesn't benefit so much from amazing hardware acceleration that you miss out on with manual management.
They get hairy really fast, and that's why ultimately when it came time to re-rethink floating point, we settled again on something with fixed bit with and inexact results.
And the better Siemens method/patent DE19929752B4 also.
bellard.org/libbf