#!/usr/bin/env swift; /****************************************************************************** * This program demonstrates how to align integers with printf() * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ import Foundation var a32:Int = 106276 var b32:Int = -2147483648 var c32:Int = 4080400 var a64:Int64 = 11294588176 var b64:Int64 = -4294967296 var c64:Int64 = 9223372036854775807 func main() -> Void { print(String(format:"|%11d|%9x|", a32, a32)) print(String(format:"|%-11d|%-9x|", a32, a32)) print(String(format:"|%011d|%09x|", a32, a32)) print(String(format:"|%11d|%9x|", b32, b32)) print(String(format:"|%-11d|%-9x|", b32, b32)) print(String(format:"|%011d|%09x|", b32, b32)) print(String(format:"|%11d|%9x|", c32, c32)) print(String(format:"|%-11d|%-9x|", c32, c32)) print(String(format:"|%011d|%09x|", c32, c32)) print(String(format:"|%20ld|%17lx|", a64, a64)) print(String(format:"|%-20ld|%-17lx|", a64, a64)) print(String(format:"|%020ld|%017lx|", a64, a64)) print(String(format:"|%20ld|%17lx|", b64, b64)) print(String(format:"|%-20ld|%-17lx|", b64, b64)) print(String(format:"|%020ld|%017lx|", b64, b64)) print(String(format:"|%20ld|%17lx|", c64, c64)) print(String(format:"|%-20ld|%-17lx|", c64, c64)) print(String(format:"|%020ld|%017lx|", c64, c64)) exit(EXIT_SUCCESS) } main()