Skip to content

Commit 40cb3e0

Browse files
authored
Merge pull request #1567 from spevans/pr_sr_3126
SR-3126: Decimal(Double.infinity) hangs forever
2 parents b89aaf0 + 4dc8ca5 commit 40cb3e0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Foundation/Decimal.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ extension Decimal : SignedNumeric {
326326
return answer;
327327
}
328328

329+
@available(*, unavailable, message: "Decimal does not yet fully adopt FloatingPoint.")
330+
public mutating func formTruncatingRemainder(dividingBy other: Decimal) { fatalError("Decimal does not yet fully adopt FloatingPoint") }
331+
329332
public mutating func negate() {
330333
guard _length != 0 else { return }
331334
_isNegative = _isNegative == 0 ? 1 : 0
@@ -389,6 +392,7 @@ extension Decimal {
389392
self.init(Int64(value))
390393
}
391394
public init(_ value: Double) {
395+
precondition(!value.isInfinite, "Decimal does not yet fully adopt FloatingPoint")
392396
if value.isNaN {
393397
self = Decimal.nan
394398
} else if value == 0.0 {
@@ -477,15 +481,25 @@ extension Decimal {
477481
public init(_ value: UInt) {
478482
self.init(UInt64(value))
479483
}
484+
480485
public init(_ value: Int) {
481486
self.init(Int64(value))
482487
}
488+
489+
@available(*, unavailable, message: "Decimal does not yet fully adopt FloatingPoint.")
490+
public static var infinity: Decimal { fatalError("Decimal does not yet fully adopt FloatingPoint") }
491+
492+
@available(*, unavailable, message: "Decimal does not yet fully adopt FloatingPoint.")
493+
public static var signalingNaN: Decimal { fatalError("Decimal does not yet fully adopt FloatingPoint") }
494+
483495
public var isSignalingNaN: Bool {
484496
return false
485497
}
498+
486499
public static var nan: Decimal {
487500
return quietNaN
488501
}
502+
489503
public static var quietNaN: Decimal {
490504
var quiet = Decimal()
491505
quiet._isNegative = 1

0 commit comments

Comments
 (0)