Skip to content

Commit

Permalink
[stdlib] Silence signaling NaN in generic conversions (apple#33902)
Browse files Browse the repository at this point in the history
  • Loading branch information
xwu committed Sep 15, 2020
1 parent 0c6129d commit 7898f0b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stdlib/public/core/FloatingPoint.swift
Expand Up @@ -1897,7 +1897,8 @@ extension BinaryFloatingPoint {
#if !os(macOS) && !(os(iOS) && targetEnvironment(macCatalyst))
case (5, 10):
guard #available(iOS 14.0, watchOS 7.0, tvOS 14.0, *) else {
self = Self._convert(from: value).value
// Convert signaling NaN to quiet NaN by multiplying by 1.
self = Self._convert(from: value).value * 1
break
}
let value_ = value as? Float16 ?? Float16(
Expand Down Expand Up @@ -1935,7 +1936,8 @@ extension BinaryFloatingPoint {
self = Self(value_)
#endif
default:
self = Self._convert(from: value).value
// Convert signaling NaN to quiet NaN by multiplying by 1.
self = Self._convert(from: value).value * 1
}
}

Expand Down

0 comments on commit 7898f0b

Please sign in to comment.