swift-foundation icon indicating copy to clipboard operation
swift-foundation copied to clipboard

Decimal

Open iCharlesHu opened this issue 2 years ago • 4 comments

Umbrella issue to track Decimal.

iCharlesHu avatar Aug 17 '23 21:08 iCharlesHu

This new implementation should follow IEEE 754.

iCharlesHu avatar Aug 17 '23 21:08 iCharlesHu

@iCharlesHu

If I understand correctly this decimal class should replace the actual Decimal class in the file Decimal+Stub.swift

public struct Decimal : Hashable, Codable, Equatable, CustomStringConvertible {
    private let fake: Double

    ...
}

If it's ok for you, I'd like to start working on this feature. As I intended, the APIs for the class should follow the guidelines reported on this documentation page, while their implementation should follow IEEE 754-2019.

aestriplex avatar Oct 09 '23 01:10 aestriplex

Hi @aestriplex! Thanks for the interest! Unfortunately Decimal is somewhat of a complicated case. The existing Decimal (aka NSDecimal) does not conform to IEEE 754 yet, which means it might be impossible to "port" Decimal as it is without breaking backwards compatibility. This also means most likely the API surface will change and it will have to go through API review.

That being said, could you get started by creating a pitch post on the Swift Form outlining what the new API surface should look like and how do you plan on implement them (what the implementation detail looks like)? We should gather as much info as possible before we proceed to code.

cc @stephentyrone @parkera @lorentey

iCharlesHu avatar Oct 12 '23 16:10 iCharlesHu

@iCharlesHu Thanks a lot. I opened a pitch post (https://forums.swift.org/t/decimal-ieee-754-2019/67871)

aestriplex avatar Oct 15 '23 22:10 aestriplex

Resolved in #664 and #735

itingliu avatar Aug 14 '24 22:08 itingliu