[swift-users] Decimal to Double?
    David Sweeris 
    davesweeris at mac.com
       
    Mon Nov 28 13:29:56 CST 2016
    
    
  
Sent from my iPhone
> On Nov 28, 2016, at 13:21, Joe Groff <jgroff at apple.com> 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 conversions between Double and Decimal.
That's what I was worried about... What's the "correct" way to express a literal as a Decimal, then? Use a string literal, `"2.1"`, instead of a float literal, `2.1`?
- Dave Sweeris 
    
    
More information about the swift-users
mailing list