### Integers and Floating-point numbers

#### Integers

`Integers`

are whole numbers with no fractional components.- Example values are
`42`

or`-23`

- Swift provides signed & unsigned integers in 8,16,32 & 64 bit forms.

// Get 8 bit unsigned int minimum & maximum value. let minValue = UInt8.min let maxValue = UInt8.max print("Min value is \(minValue) and Max value is \(maxValue)") // Min value is 0 and Max value is 255

`Int`

and `UInt`

for integers and unsigned integers.

- Use
`Int`

for integer values to current platform's native word size. - On a 32-bit platform,
`Int`

is the same size`Int32`

. On a 64-bit platform,

`Int`

is the same size`Int64`

.Use

`UInt`

for integer values to current platform's native word size.- On a 32-bit platform,
`UInt`

is the same size`UInt32`

. - On a 64-bit platform,
`UInt`

is the same size`UInt64`

.

#### Floating-Point numbers

`Double`

represents a 64-bit floating-point number.`Float`

represents a 32-bit floating-point number.`Double`

has a precision of at least 15 decimal digits.`Float`

can be as little as 6 decimal digits.`Double`

is preferred.

Click here to open actual swift-playground file for above illustration

You must log in to post a comment.