Pure Programmer
Blue Matrix


Cluster Map

Project: Aligning Integers with format()

Write a program that demonstrates left-padding, right-padding, center-padding and zero-padding using format() style formatting. Use the vertical bar character before and after the format specifier so that you can see where the output begins and ends. Print the values in both decimal and hexadecimal. Your program should reproduce the output shown using the following variables:

  • a32 = 106276
  • b32 = -2147483648
  • c32 = 4080400
  • a64 = 11294588176
  • b64 = -4294967296
  • c64 = 9223372036854775807

Output
$ swiftc AligningIntegersWithFormat.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution