A decimal literal such as 1.23 currently constructs a value via the ExpressibleByFloatLiteral protocol, which eagerly parses the literal into a binary floating-point value, losing accuracy. ExpressibleByFloatLiteral is unsuitable for supporting decimal float or fixed-point types. We should introduce an ExpressibleByDecimalLiteral protocol that can receive the significand, exponent, and sign components of a decimal literal as precise integers, so that a conforming type can produce a precise result. It could look something like this:
jckarter commentedDec 2, 2016
Additional Detail from JIRA
md5: 9de0502502b261886bad92d969cec324
duplicates:
is duplicated by:
relates to:
Issue Description:
A decimal literal such as
1.23
currently constructs a value via theExpressibleByFloatLiteral
protocol, which eagerly parses the literal into a binary floating-point value, losing accuracy.ExpressibleByFloatLiteral
is unsuitable for supporting decimal float or fixed-point types. We should introduce anExpressibleByDecimalLiteral
protocol that can receive the significand, exponent, and sign components of a decimal literal as precise integers, so that a conforming type can produce a precise result. It could look something like this:ExpressibleByFloatLiteral
could be made into a refinement ofExpressibleByDecimalLiteral
as well.The text was updated successfully, but these errors were encountered: