Are all current math methods in the System library going to be updated with the new generic math support? #74466
-
Are all current math methods in the System library going to be updated with the new generic math support? I see in the documentation of several methods in the language's library the usage of various possibilities of numeric input parameters. Are those going to be updated to use the new INumber interface? I was just curious, because I imagine that would be a lot of work... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Most (all?) of the For example, calling TNumber MySqrt<TNumber>(TNumber x)
where TNumber : IRootFunctions<TNumber>
=> TNumber.Sqrt(x); My understanding is that going forward See also: #63732 (cc @tannergooding) |
Beta Was this translation helpful? Give feedback.
Most (all?) of the
System.Math
APIs are now directly available on applicable types. So you're expected to use those in a generic math context rather thanSystem.Math
.For example, calling
Sqrt
generically looks like:My understanding is that going forward
System.Math
/MathF
will be considered legacyish and any new math operations will be added to numeric types directly. This goes for non-generic contexts too. (IE:double.Sqrt
instead ofMath.Sqrt
)See also: #63732
(cc @tannergooding)