-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Labels
affects ABIFlag: Affects ABIFlag: Affects ABIcompilerThe Swift compiler itselfThe Swift compiler itselfstandard libraryArea: Standard library umbrellaArea: Standard library umbrellaswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalFlag → feature: A feature that warrants a Swift evolution proposal
Description
| Previous ID | SR-3317 |
| Radar | rdar://problem/31414910 |
| Original Reporter | @jckarter |
| Type | Bug |
| Status | Resolved |
| Resolution | Duplicate |
Additional Detail from JIRA
| Votes | 1 |
| Component/s | Compiler |
| Labels | Bug, AffectsABI, StarterProposal |
| Assignee | None |
| Priority | Medium |
md5: 9de0502502b261886bad92d969cec324
duplicates:
- SR-920 Re-design builtin compiler protocols for literal convertible types
is duplicated by:
- SR-5678 Decimal initializer result is unexpected
relates to:
- SR-3970 Rework ExpressibleBy(Integer|Float)Literal protocols
Issue Description:
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:
protocol ExpressibleByDecimalLiteral {
associatedtype Exponent: ExpressibleByIntegerLiteral
associatedtype Significand: ExpressibleByIntegerLiteral
init(negative: Bool, significand: Significand, exponent: Exponent)
}ExpressibleByFloatLiteral could be made into a refinement of ExpressibleByDecimalLiteral as well.
Metadata
Metadata
Assignees
Labels
affects ABIFlag: Affects ABIFlag: Affects ABIcompilerThe Swift compiler itselfThe Swift compiler itselfstandard libraryArea: Standard library umbrellaArea: Standard library umbrellaswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalFlag → feature: A feature that warrants a Swift evolution proposal