I am creating a toy physics engine that works with floating point numbers, which I call realities.
I am currently using typedef;
typedef float real;
That way, I can change the precision of the floating point values to double or double, but obviously I have to recompile. I would like to be able to clearly determine the type of real at runtime, so that I can specify the accuracy through the command line or interface interface interface.
I know that typedef is determined at compile time, so I wonder if anyone has any neat ideas.
source
share