commit 3e5bc198f94c5fce2dfe63db7b26d54cd9fa56ec parent 9fa8720962d7328de09421f84457e5c677994fd8 Author: Marc Stibane <marc@taler.net> Date: Sun, 23 Aug 2026 19:20:53 +0200 AI: Amount formatting Diffstat:
| M | TalerCommon/Helper/CurrencySpecification.swift | | | 6 | +++++- |
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/TalerCommon/Helper/CurrencySpecification.swift b/TalerCommon/Helper/CurrencySpecification.swift @@ -269,7 +269,11 @@ public struct CurrencyInfo: Sendable { : " " + String(integer)) // let homeCurrency = Locale.current.currency //'currency' is only available in iOS 16 or newer madeUpStr += formatter.currencyDecimalSeparator ?? Locale.current.decimalSeparator ?? "." - madeUpStr += String(String(fraction).dropFirst()) // remove the leading 0 + // String(fraction) can be "0.5" (its own '.' would double up the separator we just + // appended) or scientific notation for tiny values (e.g. "5e-08"). + // Format with a fixed number of digits, then drop the leading "0." + let fixedFractionStr = String(format: "%.8f", fraction) + madeUpStr += String(fixedFractionStr.dropFirst(2)) // TODO: fractionalNormalDigits, fractionalTrailingZeroDigits return madeUpStr }