<div dir="ltr">If we had a rounding init for `Int`, I would imagine that we would need an enum representing the rounding strategies which would get us something like `Int(rounding:strategy:)` I think that the `.nearest` case would have an associated value representing the tie breaking strategy as well.<div><br></div><div>I might be overthinking all of this though.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 21, 2017 at 7:29 PM, Jaden Geller via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is an excellent point. I’d very much support an `Int(truncating:)` and an `Int(rounding:)` initializer from Float.<br>
<br>
Cheers,<br>
Jaden Geller<br>
<div class="HOEnZb"><div class="h5"><br>
> On May 21, 2017, at 1:30 PM, Rudolf Adamkovič via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I just wanted to ask why there’s no “truncating” label when converting say Float to Int:<br>
><br>
> let foo: Float = 1.9<br>
> let bar = Int(foo)<br>
><br>
> I do Swift tutoring on the side and the fact that “bar” equals to 1 always surprises my students.<br>
><br>
> From the Swift API Guidelines:<br>
><br>
>> In “narrowing” type conversions, though, a label that describes the narrowing is recommended.<br>
><br>
> So, why there’s no “truncating” label in this case?<br>
><br>
> Thanks!<br>
><br>
> R+<br>
><br>
> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div>