[swift-users] Different behaviour when casting Float and Double to NSNumber

Jens Alfke jens at mooseyard.com
Wed Oct 5 13:45:00 CDT 2016


> On Oct 5, 2016, at 11:36 AM, Lars-Jørgen Kristiansen <larsjk.84 at gmail.com> wrote:
> 
> And thought that i would receive a overflows when stored into 'Float' error...?

It doesn’t overflow. (I think the maximum value of Float is around 1e37.) There just isn’t enough precision to represent it exactly, which is pretty common; the usual example is that 0.1 can’t be represented exactly by any size binary floating-point.

—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161005/d006b4f0/attachment.html>


More information about the swift-users mailing list