-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hello! I'm the commenter on HN who was sincerely appreciative of the excellent UI and instructive Rust library you have built. I have the latest version with astro_float (bravo on putting it out so fast) and thought I'd share some more detailed feedback here.
If you try modifying one of the provided examples where you use a while loop for incrementing a value, notice the relative error that accumulates in just 1000 rounds (around 0.1%):
a = 0.001; while (a < 10000) { a = a + 0.001 }; a
If you measure this in ULPs (units in the last place, a common metric for arithmetic error) this is well beyond what would be considered acceptable for the majority of scientific/mathematical computations. This is because any float (even an astro_float) is inherently imprecise - in fact, even a double would be imprecise since by definition they are all binary approximations of a real value.
One option you have for representing true arbitrary precision numbers is to represent values as exact fractions a / b, where a and b are arbitrary-precision integers (e.g. num-bigint). This would solve some of the performance issues that arise when running the while loop above.
You could also look into https://gmplib.org/ and its Rust bindings. This would be my suggestion, as gmplib serves as the foundation for many other CAS systems.
In any case, best of luck on this project - it's always exciting to be the steward of your own programming language eh? 😃