How do I Mimic Number.intBitsToFloat() in C#?

The definition of 4-byte floating point number in C# and Java (and any other decent programming platform) is based on IEEE standards, so the binary format is the same.

So, it should work. And in fact it does work, but only for X64 targets (my earlier comments about .NET 2 and 4 may be wrong or right, I can't really test old platform binaries).

If you want it to work for all targets, you'll have to define it like this:

long result2 = (long)(float)(idx * result);

If you look at the generated IL, it adds a supplemental conv.r4 opcode after the multiplication. I guess this forces a float number realization in the compiled x86 code. I suppose it's a jit optimization issue.

I don't know enough about jit optimization to determine if it's a bug or not. The funny thing is the Visual Studio 2017 IDE even grays the cast (float) text and reports that cast as "redundant" or "unnecessary", so it doesn't smell good.