Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.45

Description

Description:Converts number to a string, with the specified precision.

Syntax

Syntax:number numToStr precision
Parameters:
  • number: Number - Number to convert.
  • precision: Number - Decimal points to create.
Return Value:String

Alternative Syntax

Syntax:number numToStr format
Parameters:
  • number: Number - Number to convert.
  • format: String - Formatting information, consisting of "{characters}.{precision}{notation}":
    • characters: Number - Minimum of how long the returned string should be. The string is padded with leading spaces, if needed.
    • precision: Number - Decimal points to create.
    • notation: String - Possible formats:
      • e or E: Exponential notation.
      • f: Fixed-point (integral and decimal digits).
      • g or G: The most compact of either fixed-point or exponential notation.
Return Value:String

Examples

Examples:
_number = .1234 numToStr 2; // will return "0.12"
_number = 123 numToStr 1; // will return "123.0"
_number = 123.456 numToStr "10.5f"; // will return " 123.45600"
_number = pi numToStr ".10E"; // will return "3.1415927410E+000"

Additional Information

See also: parseNumber, round, fn vbs cutDecimals
Multiplayer:
Problems:

Notes





Nick
The larger your number, the less accurate the decimal will be. IE
(400000.23) numToStr 2
will return: "400000.22"
(40000.23) numToStr 2
will return "40000.23"

The more decimal place you have the less accurate the number will be IE
(400.23) numToStr 7
will return "400.2300110"