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.

Arguments

number

A number.

mode

An integer specifying the linear units mode. The mode corresponds to the values allowed for the LUNITS AutoCAD system variable. The mode can be one of the following numbers:

1 Scientific

2 Decimal

3 Engineering (feet and decimal inches)

4 Architectural (feet and fractional inches)

5 Fractional

precision

An integer specifying the precision.

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.

Return Values

A string. The UNITMODE system variable affects the returned string when engineering, architectural, or fractional units are selected (mode values 3, 4, or 5).

Examples

Set variable x:

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"