# Converting a real number into a string: format

### 12.4.9 Converting a real number into a string: format

The format command converts real numbers into strings.

- format takes two arguments:
  - r, a real number.
  - str, a string used for formatting.
- format(str) returns r as a string with the requested formatting.

The formatting string can be one of the following:

- f (for floating format) followed by the number of digits to put after the decimal point.

  #### Example.

  Input:

  format(sqrt(2)*10^10,"f13")

  Output:

  "14142135623.7308959960938"
- s (for scientific format) followed by the number of significant digits.

  #### Example.

  Input:

  format(sqrt(2)*10^10,"s13")

  Output:

  "14142135623.73"
- e (for engineering format) followed by the number of digits to put after the decimal point, with one digit before the decimal points.

  #### Example.

  Input:

  format(sqrt(2)*10^10,"e13")

  Output:

  "1.4142135623731e+10"