본문 바로가기

iOS/ObjectiveC

Format Specifiers

  • %@ : String
  • %i : Bool
  • %d : Signed 32-bit integer
  • %D: Signed 32-bit integer
  • %u: Unsigned 32-bit integer
  • %U: Unsigned 32-bit integer
  • %x: Unsigned 32-bit integer in lowercase hexadecimal format
  • %X: Unsigned 32-bit integer in UPPERCASE hexadecimal format
  • %o: Unsigned 32-bit integer in octal format
  • %O: Unsigned 32-bit integer in octal format
  • %f: 64-bit floating-point number
  • %F: 64-bit floating-point number printed in decimal notation
  • %e: 64-bit floating-point number in lowercase scientific notation format
  • %E: 64-bit floating-point number in UPPERCASE scientific notation format
  • %g: special case %e which uses %f when less than 4 sig-figs are available, else %e
  • %G: special case %E which uses %f when less than 4 sig-figs are available, else %E
  • %c: 8-bit unsigned character
  • %C: 16-bit UTF-16 code unit
  • %s: UTF8 String
  • %S: 16-bit variant of %s
  • %p: Void Pointer in lowercase hexidecmial format with leading '0x'
  • %zx: special case %p which removes leading '0x' (For use with no-type cast)
  • %a: 64-bit floating-point number in scientific notation with leading '0x' and one hexadecimal digit before the decimal point using a 'p' to notate the exponent.
  • %A: 64-bit floating-point number in scientific notation with leading '0x' and one hexadecimal digit before the decimal point using an 'P' to notate the exponent.