Number Operations

ICE Data Services -

Number Operations


The number object represents number data or numeric constants. You should rarely need to explicitly construct this object. The formula engine automatically constructs number objects for you when assigning numbers to variables.


Number Constructors:


var n = new Number( 9 );


Typically you would just directly assign the numeric value to your variable:


var n = 9;


Number Methods


toFixed(num) Converts a floating point number to a string with a specified number of significant digits.

num is the number of significant digits to use.

var n = 12.499;

debugPrint( n.toFixed(2) + "\n" );

/* This will print 12.50  */


toString(radix) Converts a number to a string.

radix (optional) is the base that should be used to convert the number.

var n = 255;

debugPrint( n.toString(2) + "\n" );

/* This will print 255 in base 2 which is 11111111  */


toExponential(fractionDigits) Returns a string representing the number in exponential notation.

fractionDigits an integer specifying the number of digits after the decimal point.

var n = 77.1234;

debugPrint( n.toExponential(4) + "\n" );

/* This will print 7.7123e+1  */