-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved big-number formatting (#346)
* Improved integer and floating point `formatted()` methods. - [IntegerFormatStyle] I removed the trapping conversion to `Int`. IntegerFormatStyle can format big integers since (#262). - [FloatingPointFormatStyle] I removed the rounding conversion to `Double`. `formatted()` now does whatever `format(_:)` does. - [Decimal.FormatStyle] N/A (there were no conversions here). * Reenabled "Decimal Tests" in NumberFormatStyleTests.swift. - IntegerFormatStyle big integer tests succeed. - IntegerFormatStyle.Attributed big integer tests fail (output is clamped to `Int64`). * Fixes IntegerFormatStyle.Attributed. - Added a numeric string representation case to ICUNumberFormatter.Value. - IntegerFormatStyle.Attributed now uses the above instead of `Int64(clamping:)`. * Removed conversions to Decimal in each integer format style (#186). BinaryInteger's numeric string representation supersedes Decimal in the following cases: 1. IntegerFormatStyle. 2. integerFormatStyle.Attributed. 3. IntegerFormatStyle.Currency. 4. IntegerFormatStyle.Percent. * Check whether numeric string is zero using Double. The numeric string format permits redundant zeros (like `+00.00`). * Removed `isZero` and `doubleValue` from `ICUNumberFormatter.Value`. Both `isZero` and `doubleValue` were used in `ByteCountFormatStyle`. These values are now taken from `FormatInput` (`Int64`) instead. Removing them from `ICUNumberFormatter.Value` makes it easier to accommodate non-numeric payloads such as strings, which can be used to format arbitrary precision numbers. * Added `_format(_:doubleValue:)` to `ByteCountFormatStyle`. Here's an internal method simliar to the `_format(_:)` method removed earlier because wants its method back! I removed the first method to accommodate `ICUNumberFormatter.Value` cases that cannot implement `doubleValue`. The new method parameterizes the conversion instead, so you can call it whenever conversions to `Double` are possible.
- Loading branch information
Showing
6 changed files
with
18 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters