Bug 7473 - Math.Round return unexpected result
Summary: Math.Round return unexpected result
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.0
Hardware: PC Windows
: --- normal
Target Milestone: 4.8 (async)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-26 11:56 UTC by Alex Taran
Modified: 2013-06-28 13:04 UTC (History)
4 users (show)

Tags:
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:
Status:
VERIFIED FIXED

Description Alex Taran 2012-09-26 11:56:38 UTC
I have following code:

Math.Round(22.5,0, MidpointRounding.ToEven) returns 22
Math.Round(22.5,0, MidpointRounding.AwayFromZero) also returns 22 but suppose to be 23 

I've checked in standard .NET and it works pretty fine: first line returns 22 and the second one 23.

Please let me know if you need any additional information. 

Thanks.
Comment 1 Atsushi Eno 2012-10-02 13:03:13 UTC
There was a bug in mono's Math.Round() which was fixed in mono master.
https://github.com/mono/mono/commit/99d6e93a

I confirmed that this exact repro code works fine with mono master.

This is only in master and we haven't migrated our mono code base from 2.10 to 2.12 (which is not released yet). We will have to wait for 2.12 release and then the mono migration in our product line to happen.
Comment 2 Miguel de Icaza [MSFT] 2013-05-22 15:01:15 UTC
Closingl since we are about to release the master version
Comment 3 Akhilesh kumar 2013-06-28 13:04:26 UTC
Today, we have checked this issue with following builds:

XS 4.0.9(Build 12)
Xamarin.Android 4.7.11.2

Now, 
Console.WriteLine (Math.Round(22.5,0, MidpointRounding.ToEven)) returns 22
and
Console.WriteLine (Math.Round(22.5,0, MidpointRounding.AwayFromZero)) returns 23.

Hence, closing this issue and changing its status as verified.