Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14386] Decimal conformance to FloatingPoint #4216

Closed
swift-ci opened this issue Mar 22, 2021 · 4 comments
Closed

[SR-14386] Decimal conformance to FloatingPoint #4216

swift-ci opened this issue Mar 22, 2021 · 4 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-14386
Radar rdar://problem/75696891
Original Reporter ken (JIRA User)
Type New Feature
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels New Feature
Assignee @stephentyrone
Priority Medium

md5: d1384030a82997f828586050fabcfc76

Issue Description:

The FloatingPoint protocol is flexible enough to allow radix-10 storage. (BinaryFloatingPoint has the radix-2-specific parts.) Decimal isn't-a FloatingPoint, though its public interface shares a great deal of similarity with FloatingPoint. It even implements parts of FloatingPoint which make no sense on their own, like "isInfinite" and "isSignalingNaN".

It looks like FloatingPoint conformance was the plan:

> Decimal.signalingNaN
error: repl.swift:5:9: error: 'signalingNaN' is unavailable: Decimal does not yet fully adopt FloatingPoint.
Decimal.signalingNaN
        ^~~~~~~~~~~~

Foundation.Decimal:10:23: note: 'signalingNaN' has been explicitly marked unavailable here
    public static var signalingNaN: Decimal { get }
                      ^

I see a few bug reports for individual pieces of this (like SR-8173), but nothing for the whole shebang.

@typesanitizer
Copy link

@swift-ci create

@xAlien95
Copy link

FWIW, GSoC-2021 Decimal arithmetic project idea (mentored by @stephentyrone) specifies a new DecimalFloatingPoint protocol mirroring BinaryFloatingPoint.

@stephentyrone
Copy link
Member

Foundation.Decimal cannot conform to FloatingPoint because its semantics are penned in by choices that predate Swift (and predate the IEEE 754 Decimal formats). It mirrors the FloatingPoint protocol where possible, but that's the best it can do.

@swift-ci
Copy link
Contributor Author

Comment by Ken Harris (JIRA)

Can the error messages at least be changed to not say "does not yet fully adopt FloatingPoint", if that isn't actually the plan?

It's awfully misleading for an API to "mirror" an existing protocol, but not implement it fully, or correctly, or compatibly – and make it sound like it will conform someday.

Is Decimal deprecated?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants