[swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers
scanon at apple.com
Wed May 4 10:45:16 CDT 2016
First, a general +1 to these, thanks for proposing them.
In SE-0067 we spelled these “exactly” rather than “exact”.
init?<Source: Integer>(exactly value: Source)
As for –0, Int(exactly: -0.0) should *not* fail. My rationale for this is as follows:
- While information (the signbit) is lost, the essential property is that `Double(Int(exactly: -0.0)) == -0.0`.
- If we instead adopted “no information loss” as a criteria, we would back ourselves into a corner w.r.t decimal floating-point types, which have multiple representations of most values (1.0 can be encoded as 1e0 or 10e-1 or 100e-2 …). The result would be that these initializers would always fail for decimal fp inputs.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution