Skip to content

Switching MathInternal.Min/Max to managed implementations #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nanoFramework.CoreLibrary/System/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly: AssemblyProduct(".NET nanoFramework mscorlib")]
[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")]

[assembly: AssemblyNativeVersion("100.5.0.18")]
[assembly: AssemblyNativeVersion("100.5.0.19")]
24 changes: 20 additions & 4 deletions nanoFramework.CoreLibrary/System/Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,26 @@ internal static class MathInternal
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int Abs(int val);

[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int Min(int val1, int val2);
/// <summary>
/// Returns the larger of two 32-bit signed integers.
/// </summary>
/// <param name="val1">The first of two 32-bit signed integers to compare. </param>
/// <param name="val2">The second of two 32-bit signed integers to compare. </param>
/// <returns>Parameter <paramref name="val1"/> or <paramref name="val2"/>, whichever is larger.</returns>
internal static int Max(int val1, int val2)
{
return (val1 >= val2) ? val1 : val2;
}

[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int Max(int val1, int val2);
/// <summary>
/// Returns the smaller of two 32-bit signed integers.
/// </summary>
/// <param name="val1">The first of two 32-bit signed integers to compare. </param>
/// <param name="val2">The second of two 32-bit signed integers to compare. </param>
/// <returns>Parameter <paramref name="val1"/> or <paramref name="val2"/>, whichever is smaller.</returns>
internal static int Min(int val1, int val2)
{
return (val2 >= val1) ? val1 : val2;
}
}
}