commit e1b0ab6a6b47c290d75eb00b1c3f164bd6607b5e
parent 718fb95f8aeafe18f3559d95e1572dc4f61e43a1
Author: Marc Stibane <marc@taler.net>
Date: Mon, 2 Oct 2023 18:21:20 +0200
Add dd51
Diffstat:
1 file changed, 62 insertions(+), 0 deletions(-)
diff --git a/design-documents/051-fractional-digits.rst b/design-documents/051-fractional-digits.rst
@@ -0,0 +1,62 @@
+DD 51: Fractional Digits
+###############
+
+Summary
+=======
+
+This design document specifies how an amount's fractional digits should be rendered.
+
+Motivation
+==========
+
+Since different currencies have different ways to show/render fractionals, the end-user apps should follow these guidelines.
+
+Requirements
+============
+
+There is already a specification for ScopedCurrencyInfo - this needs to change
+
+We need three characteristics for fractional digits for each currency:
+
+a) the number of fractional digits [0..8] the user may enter in a TextInputField
+
+b) the number of fractional digits [0..8] to be rendered as normal characters (same font and size as the integer digits).
+ All additional fractional digits will be rendered as SuperScriptDigits as known from gas filling stations.
+ The UI should never round or truncate any amount, but always render all existing digits (except trailing zeroes, see c).
+
+c) the number of fractional digits [0..8] to be rendered as trailing zeroes (including SuperScript digits).
+ E.g. if this is 2 (and normal == 2), then render $5 as “$ 5.00”.
+ If this is 3 (and normal == 2), then render $5 as “$ 5.00⁰” with two normal trailing zeroes and one superscript trailing zero.
+
+Usually, all these three numbers have the same value, which means that in case of e.g. “2” (used for €,$,£) the user can enter cent/penny values (but not a fraction of those), these cents/pennies are always shown (even if they are 0) as two normal digits after the decimal separator, and fractions of a cent/penny are rendered as SuperScriptDigits, but only if they are not trailing zeroes.
+
+
+Proposed Solution
+=================
+
+public struct ScopedCurrencyInfo: Codable, Sendable {
+ let decimalSeparator: String // e.g. “.” for $ and ¥; “,” for €
+ let numFractionalInputDigits: Int // how much digits the user may enter after the decimalSeparator
+ let numFractionalNormalDigits: Int // €,$,£: 2; some arabic currencies: 3, ¥: 0
+ let numFractionalTrailingZeroDigits: Int // usually same as numFractionalNormalDigits, but e.g. might be 2 for ¥
+ let isCurrencyNameLeading: Bool // true for “$ 3.50”; false for “3,50 €”
+}
+
+
+Definition of Done
+==================
+
+(Only applicable to design documents that describe a new feature. While the
+DoD is not satisfied yet, a user-facing feature **must** be behind a feature
+flag or dev-mode flag.)
+
+Alternatives
+============
+
+Drawbacks
+=========
+
+Discussion / Q&A
+================
+
+(This should be filled in with results from discussions on mailing lists / personal communication.)