11.4.8 Converting a real number into a string: format
The format command takes two arguments, a real number and a
string used for formatting.
format returns the real number 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.
Input:
format(sqrt(2)*10^10,"f13")
Output:
"14142135623.7308959960938"
- s (for scientific format) followed by the
number of significant digits.
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.
Input:
format(sqrt(2)*10^10,"e13")
Output:
"1.4142135623731e+10"