I’m building a CAD-like application in C#. I’m using SlimDX
as the graphics engine, and for the number-crunching part, I build custom libraries which ultimately rely on the System.Math class, naturally.
Now, the thing is that the SlimDX
libraries use structures composed of the float data type, whereas the Math class contains several methods that only accept and return double objects, for example: Math.Ceiling, and Math.Sin. So I find myself casting my data back and forth, from float to double, constantly.
This doesn’t seem right. I’m not that concerned with the impact on performance the casts might cause (maybe I should be?), but with the numerical instabilities that may arise because of them, which is far more frightening.
So I just wanted to know how you usually manage these kinds of situations, as I’m guessing this must not be an uncommon scenario.