Skip to content
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

Fix for bug #3661. #243

Merged
merged 1 commit into from Mar 11, 2012
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions mcs/class/corlib/System/Math.cs
Expand Up @@ -351,6 +351,8 @@ public static double Round (double value, int digits)
{
if (digits < 0 || digits > 15)
throw new ArgumentOutOfRangeException (Locale.GetText ("Value is too small or too big."));
if (digits == 0)
return Round (value);

return Round2(value, digits, false);
}
Expand All @@ -376,6 +378,8 @@ public static double Round (double value, int digits, MidpointRounding mode)
{
if ((mode != MidpointRounding.ToEven) && (mode != MidpointRounding.AwayFromZero))
throw new ArgumentException ("The value '" + mode + "' is not valid for this usage of the type MidpointRounding.", "mode");
if (digits == 0)
return Round (value, mode);

if (mode == MidpointRounding.ToEven)
return Round (value, digits);
Expand Down
2 changes: 2 additions & 0 deletions mcs/class/corlib/Test/System/MathTest.cs
Expand Up @@ -965,6 +965,8 @@ public void TestDoubleRound3 ()

Assert.AreEqual (-63987.83593942D, Math.Round (-63987.83593942D, 8, MidpointRounding.ToEven), "#3B");
Assert.AreEqual (-63987.83593942D, Math.Round (-63987.83593942D, 8, MidpointRounding.AwayFromZero), "#3C");

Assert.AreEqual (1, Math.Round (0.5, 0, MidpointRounding.AwayFromZero));
}
#endif

Expand Down
2 changes: 0 additions & 2 deletions mono/metadata/sysmath.c
Expand Up @@ -66,8 +66,6 @@ gdouble ves_icall_System_Math_Round2 (gdouble value, gint32 digits, gboolean awa
return HUGE_VAL;
if (value == -HUGE_VAL)
return -HUGE_VAL;
if (digits == 0)
return ves_icall_System_Math_Round(value);
p = pow(10, digits);
#if defined (HAVE_ROUND) && defined (HAVE_RINT)
if (away_from_zero)
Expand Down