Link Search Menu Expand Document

Number.ToPrecision Method

Explanation Returns the value stored in the Number object as a string in exponential or fixed-point notation for the specified number of digits.
If the argument is omitted, the result equivalent to the ToString method is returned.
Call format var text = num.ToPrecision( [ fractionDigits ] )
Return value String in exponential or fixed-point notation.
Returns the one with the shorter expression.
Arguments integer fractionDigits Number of digits.
Specify 1 to 15.
Exception Func-4 The argument value is invalid
Example of use
var num = new Number;
num.Value = 5678.12345;
print(num.ToPrecision(3), "¥n");
print(num.ToPrecision(6), "¥n");
 
---Output result---
5.68e+003
5678.12
Related item ToExponential, ToFixed, ToString method