matku
(Mateusz)
1
Is there a way to create an infinite Decimal?
In Decimal implementation I can see that isInfinite is always false:
/// `true` iff `self` is infinity.
public var isInfinite: Bool { return false }
What I tried is:
Decimal(Double.infinity)
but it will "freeze" an execution, probably because of a while loop inside the init function:
while Double(UInt64.max - 1) < val {
val /= 10.0
exponent += 1
}
2 Likes
scanon
(Steve Canon)
2
The current Decimal type does not support infinities. That said, the init you're attempting to use should not enter an infinite loop, either (CC @itaiferber, @Philippe_Hausler).
1 Like
FWIW, this currently matches the behavior on Darwin, but I do think that trapping is likely better than looping infinitely. This is tracked by SR-3126 — we'd likely need to update the implementation on Darwin in tandem for consistency.
4 Likes
Still freezes in Sep 2020.
EDIT: Oops, probably because I'm running in an iOS 12 simulator