[Mono-bugs] [Bug 596339] New: Converting double.NaN to int doesn't generate OverflowException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 13 16:31:27 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=596339

http://bugzilla.novell.com/show_bug.cgi?id=596339#c0


           Summary: Converting double.NaN to int doesn't generate
                    OverflowException
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.4.x
          Platform: x86-64
        OS/Version: openSUSE 11.2
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Converting (but not casting!) double.NaN to an int results in different
behavior under Mono and .NET 3.5.  Consider the following program:

    using System;

    class Test {
        static void Main ()
        {
            IConvertible v = double.NaN;
            Console.WriteLine(v.ToInt32(null));
        }
    }

Under Mono, "0" is printed, while .NET gets an OverflowException.

For those with `csharp`, the one-line equivalent is:

    Convert.ChangeType(double.NaN, typeof(int));

which likewise returns 0 under Mono and results in an OverflowException on
NET.

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


More information about the mono-bugs mailing list