Skip to content

Regression: Assigned value from trig function compares equal, direct comparison compare unequal #9526

@abelbraaksma

Description

@abelbraaksma

When I run this in VS FSI (tested both x86 and x64, it only happens on x86) I get really odd behavior. In dotnet FSI it doesn't happen with this particular scenario (though the result of cos 1.0 is different for dotnet).

I'm aware that trig functions give different results depending on runtime, version and bitness, but within one session it should be stable. I put this in the "very odd" category for now, though I hope I'm just wrong and missing the obvious:

Repro steps

Copy these lines one by one:

> let x = cos 1.0;;
val x : float = 0.5403023059

> x = 0.54030230586813977;;   // use literal
val it : bool = true   // expected

> cos 1.0 = 0.54030230586813977;;   // use exactly the same literal
val it : bool = false   // certainly NOT expected

Sanity check:

> let x = cos 1.0 in x = 0.54030230586813977;;
val it : bool = false   // certainly NOT expected

How can the assigned floating point value be different from the floating point value used in the last comparison? I would expect this to be stable.

EDIT: marked a regression, as I cannot repro this in VS 2017 using the same settings, so this was introduced at some point after 2017.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions