Bug 14822 - Math.Round works differently on decimals (compared to MS .NET)
Summary: Math.Round works differently on decimals (compared to MS .NET)
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.4.4
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-09-17 23:42 UTC by artur.drobinskiy
Modified: 2015-02-06 15:29 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description artur.drobinskiy 2013-09-17 23:42:27 UTC
public void T1()
    decimal a = 1;
    Assert.AreEqual("1", a.ToString());

    a = Math.Round(a, 4);
    Assert.AreEqual("1", a.ToString());

Second assert fails - it's "1.0000" on Mono, while "1" on MS .NET
Comment 1 artur.drobinskiy 2014-10-17 05:11:49 UTC
The one above was fixed in Mono 3.10.0 ((detached/e204655)

However, the following is now broken (was working before):
public void MathRound()
	decimal value = 1.600000m;
	var roundedValue = Math.Round (value, 3);
	roundedValue.ToString ().Should ().Be ("1.600");

Comment 2 Miguel de Icaza [MSFT] 2015-02-06 15:29:59 UTC
Fixed in the new decimal implementation.