Converting real numbers to strings

### 23.5.8 Converting real numbers to strings

The format command converts a real number to a string.

- 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-point format) followed by the number of digits to put after the decimal point.
- s (for scientific format) followed by the number of significant digits.
- e (for engineering format) followed by the number of digits to put after the decimal point, with one digit before the decimal points.

#### Examples

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

“14142135623.7308959960938” |  |  |  |  |  |  |  |  |  |

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

“14142135623.73” |  |  |  |  |  |  |  |  |  |

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

“1.4142135623731e+10” |  |  |  |  |  |  |  |  |  |