[swift-evolution] SE-0170: NSNumber bridging and Numeric types

Philippe Hausler phausler at apple.com
Fri Apr 14 16:23:39 CDT 2017


> On Apr 14, 2017, at 2:11 PM, Martin R via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Apologies if I am overlooking something, but it seems to me that the proposal does not clearly define the behavior of the "exact" conversions between integer and floating point values. Does
> 
>     Int(exactly: NSNumber(value: 12.34))

The exact value of a float or double constructed NSNumber will only happen for integral values: e.g. 1.0, -32.0 etc

> 
> fail because Int cannot represent the number exactly? Or are floating point values truncated silently and the conversion to an integer fails only if it overflows? And the other way around: Does
> 
>     Double(exactly: NSNumber(value: Int64(9000000000000000001)))
>     
> fail because Double cannot represent the number exactly?

I believe this will fail because the Int64 value will exceed the mantissa representation of the Double from my current implementation. 

> 
> Regards, Martin
> 
>> On 14. Apr 2017, at 20:45, Ben Cohen via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Apologies, if you are reading this in HTML the links appear to be pointing to the incorrect proposal. 
>> 
>> Here is the corrected link:
>> 
>> https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md <https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md>
>> 
>>> On Apr 14, 2017, at 11:30 AM, Ben Cohen <ben_cohen at apple.com <mailto:ben_cohen at apple.com>> wrote:
>>> 
>>> Hello Swift community,
>>> 
>>> The review of “SE-0170: NSNumber bridging and Numeric types" begins now and runs through the Friday after next, April 14th. The proposal is available here:
>>> 	https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md <https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md>
>>> Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
>>> 	https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>> or, if you would like to keep your feedback private, directly to the review manager. When replying, please try to keep the proposal link at the top of the message:
>>> 
>>> 	Proposal link: https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md <https://github.com/apple/swift-evolution/blob/master/proposals/0170-nsnumber_bridge.md>
>>> 
>>> 	Reply text
>>> 
>>> 	Other replies
>>> 
>>> What goes into a review?
>>> 
>>> The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
>>> 
>>> 	• What is your evaluation of the proposal?
>>> 	• Is the problem being addressed significant enough to warrant a change to Swift?
>>> 	• Does this proposal fit well with the feel and direction of Swift?
>>> 	• If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
>>> 	• How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
>>> 
>>> More information about the Swift evolution process is available at https://github.com/apple/swift-evolution/blob/master/process.md <https://github.com/apple/swift-evolution/blob/master/process.md>
>>> 
>>> Thank you,
>>> 
>>> Ben Cohen
>>> Review Manager
>>> 
>>> 
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170414/5b6d1395/attachment.html>


More information about the swift-evolution mailing list