The idea of "f for Float" has been raised here. Core team members have said that it's been explicitly avoided in Swift on purpose, because in their judgment it has low readability. Instead of "5.0f" you write "5 as Float".<br><br>(Unless I'm mistaken, you can also change the default floating point type to Float in your own code.)<br><br>As to promotion for primitive values, it's something that the core team has said they're aware of and requires design. However, as Matthew said, Float could be promoted to Double but never vice versa with that feature.<br><br><div class="gmail_quote"><div dir="ltr">On Sat, Feb 18, 2017 at 09:56 Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Feb 18, 2017, at 7:23 AM, Milos Jakovljevic via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-5515226667822170133Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Are there are any plans of adding implicit conversion between primitive types?<br class="gmail_msg"><br class="gmail_msg">For example<br class="gmail_msg"><br class="gmail_msg">var float = 5.0<br class="gmail_msg"><br class="gmail_msg">func accept(float: Float) {<br class="gmail_msg"> print("this is \(float)")<br class="gmail_msg">}<br class="gmail_msg"><br class="gmail_msg"></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I recently posted a manifesto that covers value subtyping: <a href="https://gist.github.com/anandabits/5b7f8e3836387e893e3a1197a4bf144d" class="gmail_msg" target="_blank">https://gist.github.com/anandabits/5b7f8e3836387e893e3a1197a4bf144d</a>. My opinion is that this is the best way to introduce implicit conversions of the kind you’re talking about here.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">That said, without changing how Swift handles type inference for unannotated assignments from literals your example would not work with value subtyping. This is a good thing! It is because the type of `float` is actually `Double` which can represent many values that are not possible to represent with a value of type `Float`. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">In order to allow this to work the way you intuitively want we would need `float` to be assigned some kind of `***Literal` type that keeps track of the fact that the value is small enough to be represented by `Float`. This `***Literal` type would be a subtype of `Float`.</div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">This will raise a warning that double cannot be cast to float. Which is really frustrating since i always have to add type explicitly or cast it to Float. <br class="gmail_msg"><br class="gmail_msg">I would also like to propose to add "f" modifier for floats.<br class="gmail_msg">Any thoughts?<br class="gmail_msg"><br class="gmail_msg">Best,<br class="gmail_msg">Milos Jakovljevic<br class="gmail_msg">_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></div></blockquote></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>