R2SW
- Parameters
r realThe number to be converted.
width integerThe width of the string. If the width of the resulting conversion is too small the string will be filled with spaces. Use 0 for no padding.
precision integerThe amount of decimal places. The minimum possible precision is 1 (automatically set).
- comment
Returns a string representation for real r with precision digits and width. The real is correctly rounded to nearest to fit within the precision.
Lua: Raises an error if r is null.
Works similar to C/C++ printf, but does not support negative width (left-align with right padding).
Example (Lua):
R2SW(31.1235, 5, 3) == "31.124" R2SW(1, 5, 0) == " 1.0" --> two spaces followed by number- note
See:
R2Sfor a simple converter with preset values.- pure
- This function is pure. For the same values passed to it, it will always return the same value.
- patch
1.00
- Source
- common.j (suggest an edit or discuss on Github)
- return type
string- Source code
native R2SW takes real r, integer width, integer precision returns string