Standard Formats

A format code is a % (percent sign), followed by zero or more flag characters, an optional width and/or precision size, and the format character itself. The standard format codes, which are the same as in printf(), and how they print their arguments are:

  • %d or %i Integer number.

  • %u Unsigned integer number.

  • %x or %X Hexadecimal (base 16) number; upper-case letters used if upper-case X.

  • %o Octal (base 8) number.

  • %f Floating-point decimal number.

  • %e or %E Exponential floating-point number (e.g. 1.23e+05). Upper-case exponent if upper-case E.

  • %g or %G Either %f or %e format, whichever is shorter. Upper-case exponent if upper-case G.

  • %s A text string. The j flag (here) may be given for newline translation.

  • %c A single character. If the argument is a decimal, hexadecimal or octal integer, it is interpreted as the ASCII code of the character to print. If the ! flag is given, a character is decoded instead: prints the decimal ASCII code for the first character of the argument (added in version 3.01.973800000 20001109).

  • %% A percent-sign; no argument and no flags are given. This is for printing out a literal `%' in the format string, which otherwise would be interpreted as a format code.

A simple example (with its output):

<fmt "This is %s number %d (in hex: %x)." "test" 42 42>
  This is test number 42 (in hex: 2a).


Copyright © Thunderstone Software     Last updated: Oct 24 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.