[swift-evolution] Implicit truncation

Rudolf Adamkovič salutis at me.com
Sun May 21 15:30:04 CDT 2017


Hi,

I just wanted to ask why there’s no “truncating” label when converting say Float to Int:

let foo: Float = 1.9
let bar = Int(foo)

I do Swift tutoring on the side and the fact that “bar” equals to 1 always surprises my students.

From the Swift API Guidelines:

> In “narrowing” type conversions, though, a label that describes the narrowing is recommended.

So, why there’s no “truncating” label in this case?

Thanks!

R+



More information about the swift-evolution mailing list