Skip to content

Make min/max conform to IArithmatic interface to cover both integer and float #9395

@kaizhangNV

Description

@kaizhangNV

Problem Description

Our current min/max provide two overloads for integer and float, but user cannot write code to use min/max on both integer and float, e.g.

T myMin<T>(T a, T b) where     T: IArithmatic
{
       return min(a, b);
}

myMin<float>(...);
myMin<int>(...);

this code won't work.

Preferred Solution

Though, user can still use if branch to check if T is float or integer in their implementation of myMin, and do the int cast or real cast then call min. However, this is complicated. I think we can re-implement min/max function to get rid of this complexity on user end. And this won't be a breaking change.

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions