[swift-evolution] Proposal: Auto-convert for numbers when safe

Pyry Jahkola pyry.jahkola at iki.fi
Sat Dec 5 07:05:19 CST 2015


> On 05 Dec 2015, at 14:27, Jonathan Hull <jhull at gbis.com> wrote:
> 
> For example:
> • Int -> Float, Double, or CGFloat (but not the other way)

These are not "safe" conversions in general. A Float can only hold integral values up to 2^24, and Double a only up to 2^53. Neither can fit 64-bit integers and the former not even Int32.

> On a side note, can we get a version of floor() which returns an Int (or have I missed that somewhere)?


This would be nice. As would be similar versions of ceil and round.

— Pyry Jahkola
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/0c738563/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/0c738563/attachment.sig>


More information about the swift-evolution mailing list