mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Account for floating point exactly conversions and disable some tests that are caused by SR-4634
This commit is contained in:
@@ -434,15 +434,9 @@ extension Float : _ObjectiveCBridgeable {
|
||||
}
|
||||
|
||||
public init?(exactly number: NSNumber) {
|
||||
let value = number.doubleValue
|
||||
if value.isNaN {
|
||||
self = Float.nan
|
||||
} else if value.isInfinite {
|
||||
self = value.sign == .plus ? Float.infinity : -Float.infinity
|
||||
} else {
|
||||
guard Double(-Float.greatestFiniteMagnitude) <= value || value <= Double(Float.greatestFiniteMagnitude) else { return nil }
|
||||
self = Float(value)
|
||||
}
|
||||
guard let value = Double(exactly: number) else { return nil }
|
||||
guard let result = Float(exactly: value) else { return nil }
|
||||
self = result
|
||||
}
|
||||
|
||||
@_semantics("convertToObjectiveC")
|
||||
|
||||
Reference in New Issue
Block a user