Skip to content

Constant folding for long->float produces an incorrect result. #90323

Description

@tannergooding

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions