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

Decimal floating-point #7

Open
stephentyrone opened this issue Jun 25, 2019 · 7 comments
Open

Decimal floating-point #7

stephentyrone opened this issue Jun 25, 2019 · 7 comments
Labels
new module Proposals for new modules

Comments

@stephentyrone
Copy link
Member

stephentyrone commented Jun 25, 2019

Implement IEEE 754 Decimal128 (and possibly Decimal64 as well, though it's less important). This has a dependency on fixed-width integer types because we want to be able to leverage UInt128 arithmetic for the implementation.

@stephentyrone stephentyrone added enhancement New feature for existing modules new module Proposals for new modules and removed enhancement New feature for existing modules labels Jun 25, 2019
@paulrs
Copy link

paulrs commented Jun 26, 2020

We would like to second the request for this feature. For financial applications where values will not exceed the limits of UInt128 and where precision in values is key, having a Decimal128 implementation (or Decimal64) would be very helpful.

@djehrlich
Copy link

I agree with @paulrs that Decimal128 would be extremely valuable for financial applications.

@jasonbobier
Copy link

Especially since Foundation's Decimal causes a fatal error in this simple case:

let d = Decimal(exactly: 0)

and Apple seems unwilling to fix it (I reported it January 17, 2021).

@xwu
Copy link
Contributor

xwu commented Dec 2, 2021

@jasonbobier The fatal error was simply that the API was unimplemented; it's been implemented in the open-source swift-corelibs-foundation for some years now and Apple's proprietary implementation will pick up the changes on some timeline of their choosing.

@jasonbobier
Copy link

@xwu sigh "Some timeline of their choosing" is accurate. I have bugs from 2003 still open with them.

@KTSnowy
Copy link

KTSnowy commented May 23, 2022

Is there any update on this?

@mgriebling
Copy link

mgriebling commented May 26, 2022

I have an implementation of this including Decimal32, Decimal64, and Decimal128. Decimal32 is mostly tested but the other implementations require testing. This is a pure Swift implementation based on the Intel Corp Decimal Floating-Point Math Library v2.2. BTW, this is a IEEE 754 implementation.
It supports both BID (Binary Integer Decimal) and DPD (Densely Packed Decimal) encodings. IEEE 754 allows both encodings.

How would I upload this code so others can contribute? See https://github.com/mgriebling/MGDecimal for details.

stephentyrone pushed a commit that referenced this issue Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new module Proposals for new modules
Projects
None yet
Development

No branches or pull requests

7 participants