Tsallaka zuwa abun ciki
Justice Tech School

Number Literals and Overflow

Use underscores, binary, hex and octal literals. &+ wraps on overflow instead of crashing.

Example
let big = 1_000_000
let b = 0b1010, h = 0xFF, o = 0o17
print(big, b, h, o)
print(Int.max, UInt8.max)
let w = UInt8.max &+ 1
print(w)

Exercise

Hex prefix.

let h = FF

Quiz Test

What does &+ do on overflow?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.