Why are INumber.CreateX(int n) so slow compared to implicit conversion for floats and doubles?
I’m working on a Maths library, and I’d like to be able to convert it to use the new INumber<T>
interfaces in System.Numerics
. The methods in here are often on hot paths and so would be good if they can be as fast as possible, while also being pleasant to work with. I’ve been benchmarking them as I go, and noticed something that seems a little odd.
Why are INumber.CreateX(int n) so slow compared to implicit casting for floats and doubles?
I’m working on a Maths library, and I’d like to be able to convert it to use the new INumber<T>
interfaces in System.Numerics
. The methods in here are often on hot paths and so would be good if they can be as fast as possible, while also being pleasant to work with. I’ve been benchmarking them as I go, and noticed something that seems a little odd.