Skip to content

SR-3126: Decimal(Double.infinity) hangs forever #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Foundation/Decimal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ extension Decimal : SignedNumeric {
return answer;
}

@available(*, unavailable, message: "Decimal does not yet fully adopt FloatingPoint.")
public mutating func formTruncatingRemainder(dividingBy other: Decimal) { fatalError("Decimal does not yet fully adopt FloatingPoint") }

public mutating func negate() {
guard _length != 0 else { return }
_isNegative = _isNegative == 0 ? 1 : 0
Expand Down Expand Up @@ -389,6 +392,7 @@ extension Decimal {
self.init(Int64(value))
}
public init(_ value: Double) {
precondition(!value.isInfinite, "Decimal does not yet fully adopt FloatingPoint")
if value.isNaN {
self = Decimal.nan
} else if value == 0.0 {
Expand Down Expand Up @@ -477,15 +481,25 @@ extension Decimal {
public init(_ value: UInt) {
self.init(UInt64(value))
}

public init(_ value: Int) {
self.init(Int64(value))
}

@available(*, unavailable, message: "Decimal does not yet fully adopt FloatingPoint.")
public static var infinity: Decimal { fatalError("Decimal does not yet fully adopt FloatingPoint") }

@available(*, unavailable, message: "Decimal does not yet fully adopt FloatingPoint.")
public static var signalingNaN: Decimal { fatalError("Decimal does not yet fully adopt FloatingPoint") }

public var isSignalingNaN: Bool {
return false
}

public static var nan: Decimal {
return quietNaN
}

public static var quietNaN: Decimal {
var quiet = Decimal()
quiet._isNegative = 1
Expand Down