Closed AdamNorberg closed 3 years ago
API should use double, since this is an implementation detail.
Also, consider Decimal: https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=net-5.0 , which has a narrower range but many more significant figures than double
. Decimal does poorly at expressing numbers on vastly different scales but much better at preserving significant figures when operating on numbers at the same scale within its domain.
With a bit more thought, maybe Real
is the right name for this type, since it is "some real-number type of unknown size, which is much more specific and explanatory than "flex". Other suggestions?
I am very much in favor of using Real
as the name for this type, as it is clear, intuitive, and abstracts away any implementation details.
Implemented as Real
. Please review: https://github.com/Freedom-of-Form-Foundation/anatomy3d/pull/18
Engine logic currently uses
float
to surface numeric precision issues sooner. This sets up for a lot of refactoring pain later to swap it to double for production.In the engine, use a "flex" type that implements all mathematical operators as "double", which can be trivially switched to float at compile time by changing the type of the backing field.