I have commited the fixed from Kornél for all bugs that have tests. On Fri, Feb 20, 2009 at 12:14 AM, ddambro <[email protected]> wrote:
> > Hi, > > Thanks for looking into my issues. I hope my post didn't come across as > rude or anything, I was really just looking to ask if it was better to post > issues here or directly to Bugzilla. I'm sure there are far more important > issues than my weird floating point inconsistencies. > > For the curious, I am an AI researcher working on Evolutionary Computation. > I tend to use Windows and .NET to run my code, but my research group has > several large computing clusters that could massively speed up my > experiments, but they only run Linux. Also academia tends to shy away from > "Windows Only" software, so if I can say "Runs in Linux" when I release my > code to the public, it's a pretty big boon for me as well as the people who > want to run it. However, because of the floating point issues described, > experiments run on mono are not compatible with experiments run on .NET, as > over the course of a simulation, the small errors propagate over thousands > of time steps into large differences in the final AI behavior. Thus, if I > used both mono and .NET, not only would I have to be mindful of which > experiment was run on which platform when I do analysis and demonstrations, > but when I release my results to the public I would also have to mark > arbitrary sets of experiments as "mono only" or ".NET only." > > > Kornél Pál 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 - [email protected] > > http://lists.ximian.com/mailman/listinfo/mono-list > > > > > > -- > View this message in context: > http://www.nabble.com/More-.NET-and-mono-floating-point-inconsistencies-tp22018718p22114104.html > Sent from the Mono - General mailing list archive at Nabble.com. > > _______________________________________________ > Mono-list maillist - [email protected] > http://lists.ximian.com/mailman/listinfo/mono-list >
_______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
