> On Nov 28, 2016, at 11:29 AM, David Sweeris <daveswee...@mac.com> wrote: > > > > > Sent from my iPhone >> On Nov 28, 2016, at 13:21, Joe Groff <jgr...@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`?
That would certainly be more robust than using float literals, though probably slower than constructing from elements using the init(mantissa:exponent:isNegative:) initializer. -Joe _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users