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

2016-10-05 Thread Jens Alfke via swift-users
> On Oct 5, 2016, at 11:36 AM, Lars-Jørgen Kristiansen > 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

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

2016-10-05 Thread Lars-Jørgen Kristiansen via swift-users
Thanks I will give that a try on Friday when I have the hardware available! Posted an issue and will add to that when I have tried, or if the library authors can comment on how they use the NSNumber.. > 5. okt. 2016 kl. 19.31 skrev Joe Groff : > > >> On Oct 5, 2016, at 2:30 AM, Lars-Jørgen Kri

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

2016-10-05 Thread Lars-Jørgen Kristiansen via swift-users
Hmm, I actually thought about this being the reason but couldn't remember the limits. And thought that i would receive a overflows when stored into 'Float' error...? > 5. okt. 2016 kl. 19.26 skrev Jens Alfke : > > >> On Oct 5, 2016, at 2:30 AM, Lars-Jørgen Kristiansen via swift-users >> mailt

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

2016-10-05 Thread Joe Groff via swift-users
> On Oct 5, 2016, at 2:30 AM, Lars-Jørgen Kristiansen via swift-users > wrote: > > I'm working with a third party API for some external hardware. One of the > functions takes a NSNumber, and it fails to interact correctly with the > hardware if I cast a Float too NSNumber, but works as expect

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

2016-10-05 Thread Jens Alfke via swift-users
> On Oct 5, 2016, at 2:30 AM, Lars-Jørgen Kristiansen via swift-users > wrote: > > // Also noticed this: > "\(floatNumber)" // "1e+07" > "\(doubleNumer)" // "1000" Numbers around 10 million are too large to be represented exactly by a 32-bit float — the mantissa is 24 bits, including sign

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

2016-10-05 Thread Lars-Jørgen Kristiansen via swift-users
Thanks, Will file a bug. Not sure how the library uses the NSNumber since it's closed source. So it might be other inconsistencies as well.. > 5. okt. 2016 kl. 13.50 skrev Zhao Xin : > > I think you should file a bug on the inconsistence of `description`. However, > the third-party API someho

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

2016-10-05 Thread Zhao Xin via swift-users
I think you should file a bug on the inconsistence of `description`. However, the third-party API somehow using the `description` is not a good idea. Zhaoxin On Wed, Oct 5, 2016 at 5:30 PM, Lars-Jørgen Kristiansen via swift-users < swift-users@swift.org> wrote: > I'm working with a third party A

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

2016-10-05 Thread Lars-Jørgen Kristiansen via swift-users
I'm working with a third party API for some external hardware. One of the functions takes a NSNumber, and it fails to interact correctly with the hardware if I cast a Float too NSNumber, but works as expected if I use Double.. I dont know if it is related to NSNumber.stringValue since I dont kno