Skip to content

Are all current math methods in the System library going to be updated with the new generic math support? #74466

Discussion options

You must be logged in to vote

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 than System.Math.

For example, calling Sqrt generically looks like:

TNumber MySqrt<TNumber>(TNumber x)
    where TNumber : IRootFunctions<TNumber>
    => TNumber.Sqrt(x);

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 of Math.Sqrt)

See also: #63732

(cc @tannergooding)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@tannergooding
Comment options

@AnteaterStudios
Comment options

@danmoseley
Comment options

@AnteaterStudios
Comment options

Answer selected by tannergooding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants