Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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
GitHub or Developer Community 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.
public static void Main (string args)
float a = 0.7f;
float b = 100.0f;
Console.WriteLine((int) (a * b));
This seems to be an issue with the bit representation of 0.7 and the possible fact that the multiplication happens on float32 or float64 values (this depends on optimizations etc). From my tests, even unrelated changes to the test will cause .Net itself to print 69. Besides, 69 is the result also printed with the equivalent C code compiled with gcc, so I don't think this is a mono bug.
Leaving as needinfo for now if you have further insights why this is filed as major.
I don't understand the comment.
What unrelated changes to the test you made to see 69 printed on .net? I tried to modify the sample but .net still prints 70 (using csc not ilasm or similar)
I don't know what the spec says about multiplication in this case but it looks like .net does it on float32 where we do it on float64.
It's major because compiled code should give same results if we claim we are .net compatible.
So, what I did was compile with mono and ran on windows and in both cases it did print 69, which could also point to an issue with parsing/encoding the number. So I compiled it from visual studio and it did print 70, though this might have been an already tweaked test where I replaced the float type with double (and removed the f suffix) because I can't get the original test to print 70 here anymore when compiling and running with .net, it always prints 69.
FWIW, the standard says we should perform the operations on doubles, which is what mono does.
Could you attach the compiled test that returns 70 on .Net? Maybe it depends on the .net version it's been compiled or ran with.
I've done further testing as well and found out that we found .net bug.
Running csc (or mcs compiled code) on 32bit .net prints 69 when running same .exe on 64bits prints 70. If you are saying 69 is the right value then we are fine and .net has bug in 64b JIT.