At that level the rounding errors are down to how the compiler optimises
the calculations, whether the calculations are performed as actual 32bit
operations, or if they inflate to 64bit and then are rounded back to 32bit
results, the order of the operations and the actual CPU instructions used
to compute the value.

.NET follows the IEEE 754 standard for floating point operations.

Alan

On 15 May 2016 at 13:02, MarLOne <infoseeker...@gmail.com> wrote:

> Hi,
>
> I am using MonoDevelop 5.10 and
> the runtime Mono 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 16 13:19:08 UTC 20
> in
> a Mint17 (64bit) environment.
>
> I am compiling the following code into .Net 4/4.5 and hence I believe I am
> using dmcs version 4.2.3.0
>
> A friend posts me the following piece of code:
> public void Test()
> {
>     float delta = 0.1f + 0.2f - 0.3f;
>     Console.WriteLine( "Delta is {0}", delta );
> }
>
> Since this is a floating point operation I do not expect that delta to be
> absolutely zero. But I don't expect a number like this -7.450581E-09.
>
> A similar test in C produces an absolute 0 even when it does not involve
> static expression.
>
> Any comment or explanation?
>
> Rover
>
>
>
>
>
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/Why-is-0-1f-0-2f-0-3f-produces-such-a-large-error-number-tp4667837.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to