# JavaScript Number Methods in Geogebra

//JavaScript Number Methods // Number() alert(Number(true)+"\n"+ Number(false)+"\n"+ Number("10")+"\n"+ Number(" 10")+"\n"+ Number("10 ")+"\n"+ Number(" 10 ")+"\n"+ Number("10.33")+"\n"+ Number("10,33")+"\n"+ Number("10 33")+"\n"+ Number("John")+"\n"+ Number(new Date("2017-09-30"))); //toPrecision() var x = 9.656; alert(x.toPrecision()+"\n"+ x.toPrecision(2) +"\n"+ x.toPrecision(4)+"\n"+ x.toPrecision(6)); //toFixed() var x = 9.656; alert(x.toFixed(0)+"\n"+ x.toFixed(2)+"\n"+ x.toFixed(4)+"\n"+ x.toFixed(6)); //toString() var myNumber = 32; alert(myNumber.toString(10)+"\n"+ myNumber.toString(32)+"\n"+ myNumber.toString(16)+"\n"+ myNumber.toString(8)+"\n"+ myNumber.toString(2)); var x = 123; x.toString(); //Number() var y1 = new Number(123); var y2 = new Number(500); alert(y1+"\n"+y2); //toExponential() var x = 9.656; alert(x.toExponential(2)+"\n"+ x.toExponential(4)+"\n"+ x.toExponential(6)); //Number valueOf() var x = 123; alert(x.valueOf()+"\n"+ (123).valueOf()+"\n"+ (100 + 23).valueOf()); // parseInt alert(parseInt("10")+"\n"+ parseInt("10.33")+"\n"+ parseInt("10 20 30")+"\n"+ parseInt("10 years")+"\n"+ parseInt("years 10")); //parseFloat alert(parseFloat("10")+"\n"+ parseFloat("10.33")+"\n"+ parseFloat("10 20 30")+"\n"+ parseFloat("10 years")+"\n"+ parseFloat("years 10")); //Number.isInteger() alert(Number.isInteger(0.5)+"\n"+ Number.isInteger('123')+"\n"+ Number.isInteger(false)+"\n"+ Number.isInteger(Infinity)+"\n"+ Number.isInteger(-Infinity)+"\n"+ Number.isInteger(0/0)); //Number.isFinite() alert(Number.isFinite(1/0)+"\n"+ Number.isFinite(10/5)+"\n"+ Number.isFinite(0/0)); //Number.isSafeInteger() alert(Number.isSafeInteger(0.5)+"\n"+ Number.isSafeInteger(0/0)); //Number.isNaN() alert(Number.isNaN(NaN)+"\n"+ Number.isNaN(0/0)); //Number.MAX_VALUE var x = Number.MAX_VALUE; alert(x); //Number.MIN_VALUE var x = Number.MIN_VALUE; alert(x); //Number.POSITIVE_INFINITY; var x = Number.POSITIVE_INFINITY; alert(x); //Number.NEGATIVE_INFINITY var x = Number.NEGATIVE_INFINITY; alert(x); // Number.NaN var x = Number.NaN; alert(x);