(rtos number [mode [precision]])


Convert that real number to a string.


This function converts a real number to a string. The argument number is the real number you want to convert.

Mode and precision arguments are optional arguments. The mode (1 through 5) selects the format of the string:

Mode Meaning
1 Scientific
2 Decimal
3 Engineering
4 Architectural
5 Fractional

The precision argument allows you to select the number of places after the decimal point. The range is 0 to 8.

Examples

Code Returns Format
(rtos 15.35 1 4) "1.5350E+001" Scientific.
(rtos 15.35 2 4) "15.3500" Decimal.
(rtos 15.35 3 4) "1'-3.3500" Engineering.
(rtos 15.35 4 4) "1'-3 3/8" Architectural.
(rtos 15.35 5 4) "15 3/8" Fractional.

NOTE  When you leave them out, the mode and precision arguments read the settings of system variables LUNITS (default = decimal units) and LUPREC (default = 4 decimal places). Thus, to automatically use the current system settings, simply leave out mode and precision.

Tell me about...

(atof string)

(atoi string)

LISP Compatibility

Programming Overview of LISP (LISt Processing) Language