Skip to content

Commit 7898f0b

Browse files
authored
[stdlib] Silence signaling NaN in generic conversions (#33902)
1 parent 0c6129d commit 7898f0b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stdlib/public/core/FloatingPoint.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,8 @@ extension BinaryFloatingPoint {
18971897
#if !os(macOS) && !(os(iOS) && targetEnvironment(macCatalyst))
18981898
case (5, 10):
18991899
guard #available(iOS 14.0, watchOS 7.0, tvOS 14.0, *) else {
1900-
self = Self._convert(from: value).value
1900+
// Convert signaling NaN to quiet NaN by multiplying by 1.
1901+
self = Self._convert(from: value).value * 1
19011902
break
19021903
}
19031904
let value_ = value as? Float16 ?? Float16(
@@ -1935,7 +1936,8 @@ extension BinaryFloatingPoint {
19351936
self = Self(value_)
19361937
#endif
19371938
default:
1938-
self = Self._convert(from: value).value
1939+
// Convert signaling NaN to quiet NaN by multiplying by 1.
1940+
self = Self._convert(from: value).value * 1
19391941
}
19401942
}
19411943

0 commit comments

Comments
 (0)