• Pure

    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

    Parameters

    • r: number

      The number to be converted.

    • width: number

      The 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: number

      The amount of decimal places. The minimum possible precision is 1 (automatically set).

    Returns string

    Note

    See: R2S for a simple converter with preset values.

Generated using TypeDoc