Download presentation
Presentation is loading. Please wait.
Published byOswald Kelley Modified over 8 years ago
1
Numbers © Copyright 2014, Fred McClurg All Rights Reserved
2
JavaScript Numbers What is a number? All numbers (i.e. integers and floats) have the same type (i.e. number) Examples: var count = 4; // number var localPi = 3.14; // number var exponPi = 0.314e+1; 2 numbers.html
3
Numeric Property: ±Infinity What is a Infinity? A number that exceeds the limit of a floating point number. Examples: // infinity computed console.log( 1 / 0 ); // negative infinity computed console.log( -1 / 0 ); 3 infinity.html
4
Numeric Property: NaN What is a NaN? NaN is a “Not a Number”. Examples: // "not a number" computed console.log( 0 / 0 ); // also NaN computed console.log( 100 / "Apple" ); 4 nan.html
5
Math Properties & Methods What are built-in properties or methods? Common functions available via Math object: http://www.w3schools.com/jsref/jsref_obj_math.asp Examples: var pi = Math.PI; // math property for PI console.log( pi ); // round to nearest integer var cents = Math.round(12.567); // math method console.log( cents ); // random float between zero and one var guess = Math.random(); console.log( guess ); 5 mathPropMeth.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.