Numeric literals and formatting in Swift

Numeric literals can contain extra formatting to make them easier to read. Both integers and floating point numbers can eb padded with extra zero and underscores to help with readability. This won’t affect their value.

 

Example:

var integerFormatter = 5_000_000

var floatFormatter = 000_123.45

 

Leave a Reply