Number (Number - JavaScript)

Creates a new Number object.

Defined in

Number (Standard - JavaScript)

Syntax

Number()

Number(value:number)

Parameters Description
value A numeric value. The value is empty if not specified.

Examples

(1) This example prints a number in exponential format with various precisions.
function p(stuff) {
 	print("<<<" + stuff + ">>>");
}

try {
	n = new Number(Math.sqrt(2));
	p(n.toPrecision(16)); // prints <<<1.4142135623730951>>>
	
} catch(e) {
	p("Error = " + e);
}

(2) This example is essentially the same as above.

function p(stuff) {
 	print("<<<" + stuff + ">>>");
}

try {
	n = new Number();
	n = Math.sqrt(2);
	p(n.toPrecision(16)); // prints <<<1.4142135623730951>>>
	
} catch(e) {
	p("Error = " + e);
}