[Mono-list] More .NET and mono floating point inconsistencies

Rodrigo Kumpera kumpera at gmail.com
Mon Feb 16 09:30:41 EST 2009


Kornel,

I'll try to review your patch on the bugzilla issue this week. Sorry for the
delay.

Cheers,
Rodrigo

On Sun, Feb 15, 2009 at 10:54 AM, Kornél Pál <kornelpal at gmail.com> wrote:

> Hi,
>
> Thanks for the test cases, I'll invetigate these as well and try to fix
> them.
>
> The best way to get bugs fixed is to produce test cases and report them
> in buzilla.
>
> You can help more if you are able to provide a patch to fix the bugs.
>
> Note that for some reasons Novell guys seem to ignore this bug mostly
> because they have other things to do and their approval is required for
> these changes.
>
> Could you please describe your scenario (application name, purpose, etc.
> if they are public) where you need these floating point roundings and
> describe why these bugs are critical for you.
>
> Providing some description may raise component owners' attention.
>
> Kornél
>
> ddambro wrote:
> > I previously posted about some differences I noticed between the floating
> > point math in .NET and mono
> >
> http://www.nabble.com/Mono-and-.Net-Floating-Point-Inconsistencies-to21428695ef1367.html
> > here .  The bug report can be found
> > https://bugzilla.novell.com/show_bug.cgi?id=467201 here .  The patch
> > provided (Thank you!) fixes several issues I was encountering, but
> > unfortunately it led me to discover a couple more.  The following two
> code
> > samples were tested x86 machines using Linux mono 2.2 with the patch
> found
> > in the bug report, a clean Windows mono 2.0.1, and the latest version of
> > .NET targeting 3.0 framework and x86.
> >
> > ---
> > 1.
> >
> > using System;
> > using System.Runtime.CompilerServices;
> >
> > class Testing
> > {
> >     [MethodImpl(MethodImplOptions.NoInlining)]
> >     public static void Main()
> >     {
> >         float f1=200;
> >
> >         float distance=Distance(300, 500, 387.5f, 362.5f);
> >
> >         float dist = 1 - (distance / f1);
> >
> >         float distSqud = dist * dist;
> >
> >         Console.WriteLine(distSqud.ToString("R"));
> >
> >         foreach (byte b in BitConverter.GetBytes(distSqud))
> >             Console.WriteLine(b);
> >
> >     }
> >
> >     public static float Distance(float x1, float y1, float x2, float y2)
> >     {
> >         float xDist = x1 - x2;
> >         float yDist = y1 - y2;
> >         float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist);
> >         return dist;
> >     }
> >
> > On .NET this code produces:
> > 0.0342619047
> > 54
> > 86
> > 12
> > 61
> >
> > and on mono it produces:
> > 0.03426191
> > 55
> > 86
> > 12
> > 61
> >
> > ---
> > 2.
> >
> > using System;
> > using System.Runtime.CompilerServices;
> >
> > class Testing
> > {
> >     [MethodImpl(MethodImplOptions.NoInlining)]
> >     public static void Main()
> >     {
> >         float distance = Distance(616.161255f, 391.2928f, 550.8382f,
> > 131.006973f);
> >         Console.WriteLine(distance.ToString("R"));
> >
> >         foreach (byte b in BitConverter.GetBytes(distance))
> >             Console.WriteLine(b);
> >     }
> >
> >     public static float Distance(float x1, float y1, float x2, float y2)
> >     {
> >         float xDist = x1 - x2;
> >         float yDist = y1 - y2;
> >         float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist);
> >
> >         Console.WriteLine(dist.ToString("R"));
> >
> >         foreach (byte b in BitConverter.GetBytes(dist))
> >             Console.WriteLine(b);
> >
> >         return dist;
> >     }
> > }
> >
> > On .NET this code produces:
> > 268.3576
> > 198
> > 45
> > 134
> > 67
> > 268.3576
> > 198
> > 45
> > 134
> > 67
> >
> > and on mono it produces:
> > 268.357635
> > 199
> > 45
> > 134
> > 67
> > 268.357635
> > 199
> > 45
> > 134
> > 67
> >
> > ---
> > These seem to be very similar to the issues I was encountering before,
> but
> > they are not fixed by the patch.  What is the best way to resolve these
> > inconsistencies?
> >
> > Thanks,
> > David
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090216/c1933d09/attachment.html 


More information about the Mono-list mailing list