Converts a number into a string
(rtos number [mode [precision]])
The rtos function returns a string that is the representation of number according to the settings of mode, precision, and the system variables UNITMODE, DIMZIN, LUNITS, and LUPREC.
The mode and precision arguments correspond to the system variables LUNITS and LUPREC. If you omit the arguments, rtos uses the current settings of LUNITS and LUPREC.
A string. The UNITMODE system variable affects the returned string when engineering, architectural, or fractional units are selected (mode values 3, 4, or 5).
Command: (setq x 17.5)
17.5
Convert the value of x to a string in scientific format, with a precision of 4:
Command: (setq fmtval (rtos x 1 4))
"1.7500E+01"
Convert the value of x to a string in decimal format, with 2 decimal places:
Command: (setq fmtval (rtos x 2 2))
"17.50"
Convert the value of x to a string in engineering format, with a precision of 2:
Command: (setq fmtval (rtos x 3 2))
"1'-5.50\""
Convert the value of x to a string in architectural format:
Command: (setq fmtval (rtos x 4 2))
"1'-5 1/2\""
Convert the value of x to a string in fractional format:
Command: (setq fmtval (rtos x 5 2))
"17 1/2"
Setting UNITMODE to 1 causes units to be displayed as entered. This affects the values returned by rtos for engineering, architectural, and fractional formats, as shown in the following examples:
Command: (setvar "unitmode" 1)
1
Command: (setq fmtval (rtos x 3 2))
"1'5.50\""
Command: (setq fmtval (rtos x 4 2))
"1'5-1/2\""
Command: (setq fmtval (rtos x 5 2))
"17-1/2"
-
The
String Conversions topic in the AutoLISP Developer's Guide .