Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2521f81

Browse files
forkidsyme
authored andcommitted
Equality is 0 (dotnet#4493)
* Create a test that shows broken comparison on float32* fix comparison of float32
1 parent4952f84 commit2521f81

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

‎src/fsharp/FSharp.Core/prim-types.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4167,7 +4167,7 @@ namespace Microsoft.FSharp.Core
41674167
else(#"ceq" e1 e1: int #)
41684168
when^T: float32=if(#"clt" e1 e2: bool #)then(-1)
41694169
elif(#"cgt" e1 e2: bool #)then(1)
4170-
elif(#"ceq" e1 e2: bool #)then(1)
4170+
elif(#"ceq" e1 e2: bool #)then(0)
41714171
elif(#"ceq" e2 e2: bool #)then(-1)
41724172
else(#"ceq" e1 e1: int #)
41734173
when^T: char=if(#"clt.un" e1 e2: bool #)then(-1)else(#"cgt.un" e1 e2: int #)

‎tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,3 +816,16 @@ type RangeTests() =
816816
if System.UIntPtr.Size>=8then RangeTestsHelpers.unsigned(System.UIntPtr System.UInt64.MinValue)(System.UIntPtr System.UInt64.MaxValue)
817817

818818

819+
openNonStructuralComparison
820+
821+
822+
[<TestFixture>]
823+
typeNonStructuralComparisonTests()=
824+
825+
[<Test>]
826+
member__.CompareFloat32()=// https://github.com/Microsoft/visualfsharp/pull/4493
827+
828+
letx=32|> float32
829+
lety=32|> float32
830+
letcomparison= compare x y
831+
Assert.AreEqual(0, comparison)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp