Re: [swift-users] Implementing signum

2016-11-28 Thread Dave Abrahams via swift-users
on Sun Nov 20 2016, Hooman Mehr wrote: > Let me explain this a bit further: > > Swift generic programming is very different from C++ template programming. > Swift compiler needs to > type-check generic code on spot, not while instantiating the template > (because in Swift, > instantiation can

Re: [swift-users] Implementing signum

2016-11-28 Thread Dave Abrahams via swift-users
on Sun Nov 20 2016, Hooman Mehr wrote: > Let me explain this a bit further: > > Swift generic programming is very different from C++ template > programming. Swift compiler needs to type-check generic code on spot, > not while instantiating the template (because in Swift, instantiation > can occu

[swift-users] Dimensional analysis

2016-11-28 Thread Rick Mann via swift-users
My earlier post about converting Decimal to Double was part of a larger effort by me to write a calculator app that supports dimensional analysis/unit conversions. I've explored some existing libraries on the topic, ranging from this one in Common Lisp (

Re: [swift-users] Decimal to Double?

2016-11-28 Thread David Sweeris via swift-users
> On Nov 28, 2016, at 13:43, Joe Groff via swift-users > wrote: > > >> On Nov 28, 2016, at 11:42 AM, Nevin Brackett-Rozinsky >> wrote: >> >> On Mon, Nov 28, 2016 at 2:21 PM, Joe Groff via swift-users >> wrote: >> ExpressibleByFloatLiteral uses a binary float initial value and so doesn't

Re: [swift-users] Indirectly calling functions through assembly

2016-11-28 Thread Joe Groff via swift-users
> On Nov 26, 2016, at 5:20 PM, Krishna Mannem via swift-users > wrote: > > I’ve been messing around with swift and trying to figure out the internals > for fun. I’ve been running into a seg fault while running this gist > (https://gist.github.com/krishnamannem/032aa7b568f82297ba2f88041518085d

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Joe Groff via swift-users
> On Nov 28, 2016, at 11:42 AM, Nevin Brackett-Rozinsky > wrote: > > On Mon, Nov 28, 2016 at 2:21 PM, Joe Groff via swift-users > wrote: > ExpressibleByFloatLiteral uses a binary float initial value and so doesn't > guarantee decimal accuracy > > That seems like a flaw in ExpressibleByFloat

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Nevin Brackett-Rozinsky via swift-users
On Mon, Nov 28, 2016 at 2:21 PM, Joe Groff via swift-users < swift-users@swift.org> wrote: > ExpressibleByFloatLiteral uses a binary float initial value and so doesn't > guarantee decimal accuracy That seems like a flaw in ExpressibleByFloatLiteral that should be fixed. Did anyone ever submit a

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Stephen Canon via swift-users
> On Nov 28, 2016, at 2:29 PM, David Sweeris via swift-users > wrote: > > Sent from my iPhone >> On Nov 28, 2016, at 13:21, Joe Groff wrote: >> >> It really shouldn't be, since ExpressibleByFloatLiteral uses a binary float >> initial value and so doesn't guarantee decimal accuracy. I'd recom

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Joe Groff via swift-users
> On Nov 28, 2016, at 11:29 AM, David Sweeris wrote: > > > > > Sent from my iPhone >> On Nov 28, 2016, at 13:21, Joe Groff wrote: >> >> It really shouldn't be, since ExpressibleByFloatLiteral uses a binary float >> initial value and so doesn't guarantee decimal accuracy. I'd recommend usin

Re: [swift-users] Decimal to Double?

2016-11-28 Thread David Sweeris via swift-users
Sent from my iPhone > On Nov 28, 2016, at 13:21, Joe Groff wrote: > > It really shouldn't be, since ExpressibleByFloatLiteral uses a binary float > initial value and so doesn't guarantee decimal accuracy. I'd recommend using > init(mantissa:exponent:isNegative:) instead, and minimizing any c

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Joe Groff via swift-users
> On Nov 28, 2016, at 9:22 AM, Alex Blewitt via swift-users > wrote: > > NSDecimal conforms to the ExpressibleBy(Float|Integer)Literal, but that just > means it can be created from a literal value, not the other way around: > > https://github.com/apple/swift-corelibs-foundation/blob/108a5b000

Re: [swift-users] [swift-evolution] [Proposal] Linux specific Package.swift file

2016-11-28 Thread Chris Lattner via swift-users
> On Nov 22, 2016, at 3:28 AM, rintaro ishizaki via swift-users > wrote: > > Hi Said, > > Since `Package.targets` is a mutable public property, > https://github.com/apple/swift-package-manager/blob/master/Sources/PackageDescription/Package.swift#L60-L67 > >

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Alex Blewitt via swift-users
NSDecimal conforms to the ExpressibleBy(Float|Integer)Literal, but that just means it can be created from a literal value, not the other way around: https://github.com/apple/swift-corelibs-foundation/blob/108a5b0006912c6cf6b59e4954255237bf01b67a/Foundation/NSDecimal.swift#L319-L329

Re: [swift-users] Decimal to Double?

2016-11-28 Thread David Sweeris via swift-users
> On Nov 28, 2016, at 09:48, Philippe Hausler via swift-users > wrote: > > This might be a bit nicer since that is relying on NSNumber bridges. You can > bridge to NSDecimalNumber directly like this: > > (Decimal(1.0) as NSDecimalNumber).doubleValue > > (but perhaps we should consider addin

[swift-users] Indirectly calling functions through assembly

2016-11-28 Thread Krishna Mannem via swift-users
I’ve been messing around with swift and trying to figure out the internals for fun. I’ve been running into a seg fault while running this gist (https://gist.github.com/krishnamannem/032aa7b568f82297ba2f88041518085d), the seg fault happens in the print(). Going through the execution with lldb I

[swift-users] Strange Behaviour on implementing Equatable on Generic Struct in Swift

2016-11-28 Thread Choi Chi Piu via swift-users
I have come across a problem when implementing Equatable on Generic Struct. I have posted the detail on StackOverflow . Would like to know how to correctly implement Equatable on Gene

[swift-users] [Proposal] Linux specific Package.swift file

2016-11-28 Thread Said Sikira via swift-users
Hello everyone, Currently, we use Package.swift manifest file when defining our packages. Within the manifest file you define your targets, dependencies, excluded folders etc. This works fairly well while you’re using frameworks that exist on all supported platforms (ex. Foundation). The main pro

Re: [swift-users] [swift-evolution] [Proposal] Linux specific Package.swift file

2016-11-28 Thread rintaro ishizaki via swift-users
Hi Said, Since `Package.targets` is a mutable public property, https://github.com/apple/swift-package-manager/blob/master/Sources/PackageDescription/Package.swift#L60-L67 you can freely mutate it later, as documented in https://github.com/apple/swift-package-manager/blob/master/Documentation/Refer

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Philippe Hausler via swift-users
This might be a bit nicer since that is relying on NSNumber bridges. You can bridge to NSDecimalNumber directly like this: (Decimal(1.0) as NSDecimalNumber).doubleValue (but perhaps we should consider adding initializers that follow the same pattern as Double that don’t have to bridge to solve

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Rick Mann via swift-users
Ugh. Thanks! > On Nov 28, 2016, at 02:40 , Alex Blewitt wrote: > > You can wrap it with an NSDecimalNumber, and then cast it to a Double from > there: > > Double(NSDecimalNumber(decimal:Decimal(1.0))) > > Alex > >> On 28 Nov 2016, at 10:13, Rick Mann via swift-users >> wrote: >> >> How do

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Alex Blewitt via swift-users
You can wrap it with an NSDecimalNumber, and then cast it to a Double from there: Double(NSDecimalNumber(decimal:Decimal(1.0))) Alex > On 28 Nov 2016, at 10:13, Rick Mann via swift-users > wrote: > > How do I get a Double from a Decimal? > > TIA, > > -- > Rick Mann > rm...@latencyzero.com

[swift-users] Decimal to Double?

2016-11-28 Thread Rick Mann via swift-users
How do I get a Double from a Decimal? TIA, -- Rick Mann rm...@latencyzero.com ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users