...And I do have to take one statement back: if I recall, using the label &quot;truncating&quot; was considered and rejected for converting from floating point values to integers. The reasoning was that, in Swift, the term &quot;truncating&quot; is intended to be used exclusively for the truncating of bit patterns (such as Int(truncatingOrExtending: 42 as Int8)). Although C has &quot;trunc&quot;, the same function is deliberately known in Swift as &quot;rounded toward zero.&quot; Even the documentation for Int.init(_: Float) deliberately uses that terminology and never calls it &quot;truncating.&quot;<br><div class="gmail_quote"><div dir="ltr">On Sun, May 21, 2017 at 23:44 Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Both `rounded()` and `round()` are already provided by FloatingPoint. As with all proposed API additions, you&#39;d need to demonstrate why Int.init(rounding: value) is necessary given that Int.init(value.rounded()) is already possible. With so many initializers on Int already, I highly doubt that adding more is a good move.</div><div><br></div><div>There is `Int.init?(exactly:)` for the originally requested feature. Now, if one were to design from scratch, then perhaps Int.init(truncating:) would be the most consistent name, but the unlabeled spelling is not harmful, as `Int.init(_: Float)` is after all a non-failable initializer that converts from a floating point value to an integer value. Put another way, if the current unlabeled spelling weren&#39;t used for what it is today, then there could be no unlabeled initializer on an integer type that takes a floating point argument.</div><div><br>In any case, this issue is settled. The integer protocols have been formally reviewed not once but twice, and not all of the approved design has even been implemented yet. One cannot go back and bikeshed endlessly what has already been approved.</div><div><br></div><div><br><div class="gmail_quote"><div>On Sun, May 21, 2017 at 21:22 Robert Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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:<br>
<br>
Int.init(rounding number: FloatingPoint, _ rule: FloatingPointRoundingRule)<br>
Int.init(truncating number: FloatingPoint)<br>
<br>
The latter would be source breaking and require migration, so we&#39;d need it before Swift 4. This seems like a pretty easy change to make, though.<br>
<br>
Also, this probably isn&#39;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.<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div></blockquote></div>