[SR-3317] Literal protocol for decimal literals should support precise decimal accuracy #45905
Labels
affects ABI
Flag: Affects ABI
compiler
The Swift compiler in itself
duplicate
Resolution: Duplicates another issue
improvement
standard library
Area: Standard library umbrella
swift evolution proposal needed
Flag → feature: A feature that warrants a Swift evolution proposal
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: