Files
pebble/examples/basic/23_format_spec.peb

23 lines
333 B
Plaintext

// Basic type
let a = 42
print(f"int: {a:d}; hex: {a:x}; HEX: {a:X}; oct: {a:o}; bin: {a:b}")
// Grouping
let b = 1234567890
print(f"{b:,}")
print(f"{b:_}")
let c = 1234.5678
print(f"{c:,._}")
print(f"{c:_.,}")
// Sign
// Percentage
let pts = 19
let total = 22
print(f"Correct answers: {pts/total:.2%}")
// Precision
// Complex