[Mono-bugs] [Bug 557689] New: System.Math::Round gives incorrect results

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 23 05:41:18 EST 2009



           Summary: System.Math::Round gives incorrect results
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Core
        AssignedTo: jbevain at novell.com
        ReportedBy: lambourg at adacore.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

Created an attachment (id=328940)
 --> (http://bugzilla.novell.com/attachment.cgi?id=328940)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us)
AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10

Loading the largest float64 number strictly lower than 0.5, and calling
Math.Round gives 1, while it should always return 0, whatever the
ModpointRounding value given.

The following il code demonstrates the issue:

      ldc.r8 float64(0x3FDFFFFFFFFFFFFF) // largest r8 number strictly less
than 0.5
      ldc.i4.1 // away from zero value
      call float64 class [mscorlib]System.Math::Round(float64, valuetype
[mscorlib]System.MidpointRounding) // expected result is 0, as 0.4999999999
should always be rounded to 0, whatever the MidpointRounding value
      call void class [mscorlib]System.Console::WriteLine(float64)

The output is 1 on mono, while it should be 0.

I tested this incorrect behavior on both linux (x86, x86_64) and osx (x86),
with very recent snapshots of mono.

Reproducible: Always

Steps to Reproduce:
1.compile the attached file (ilasm /exe testfloat.il)
2.run the example (mono ./testfloat.exe)
Actual Results:  
displays 1

Expected Results:  
should display 0

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list