Consider the following program:
using System;
using System.Runtime.CompilerServices;
long l = 0x4000_0040_0000_0001L;
Console.WriteLine((float)l);
Test1(l);
Test2(l);
[MethodImpl(MethodImplOptions.NoInlining)]
static void Test1(long l) => Console.WriteLine((float)l);
[MethodImpl(MethodImplOptions.NoInlining)]
static void Test2(long l) => Console.WriteLine((float)(double)l);
The expected result is:
4.6116866E+18
4.6116866E+18
4.611686E+18
The actual result is:
4.611686E+18
4.6116866E+18
4.611686E+18
Consider the following program:
The expected result is:
The actual result is: