[swift-evolution] Implicit truncation
Robert Bennett
rltbennett at icloud.com
Sun May 21 21:15:48 CDT 2017
Swift already has the FloatingPointRoundingRule enum — used in mutating func round(_ rule: FloatingPointRoundingRule) in FloatingPoint — which has all of that behavior as separate cases. So all that would be added to the language would be:
Int.init(rounding number: FloatingPoint, _ rule: FloatingPointRoundingRule)
Int.init(truncating number: FloatingPoint)
The latter would be source breaking and require migration, so we'd need it before Swift 4. This seems like a pretty easy change to make, though.
Also, this probably isn't the thread for this, but I noticed that the FloatingPoint protocol has a mutating round method, but not a non-mutating rounded() method. Would that be worth adding as well? It feels odd to not have the mutating/non-mutating pair of methods there.
More information about the swift-evolution
mailing list