How to group digits in Swift
Issue #26
When working on Scale I think it’s good to have a way to group the digit so that it is easier to reason
Luckily, Swift already supports this. See The Swift Programming Language - Numeric Literals
Numeric literals can contain extra formatting to make them easier to read. Both integers and floats can be padded with extra zeros and can contain underscores to help with readability. Neither type of formatting affects the underlying value of the literal
1 | let paddedDouble = 000123.456 |
Talking about grouping digits after the decimal point, it is interesting too Convention of digit grouping after decimal point
So now we have
1 | public enum MetricUnit: Double { |