8FuncObjIII - The Math Object The Math Object also provides...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
The Math Object The Math Object also provides a lot of calculation methods: Method Description Example Math.abs( x ) absolute value of x Math.abs( 7.2 ) is 7.2 Math.abs( 0 ) is 0 Math.abs( -5.6 ) is 5.6 Math.round( x ) rounds x to the closest integer Math.round( 9.75 ) is 10 Math.round( 9.25 ) is 9 Math.ceil( x ) rounds x to the smallest integer not less than x Math.ceil( 9.2 ) is 10 Math.ceil( -9.8 ) is -9 Math.floor( x ) rounds x to the largest integer not greater than x Math.floor( 9.2 ) is 9 Math.floor( -9.8 ) is -10 Math.max(x,y,. .) largest value in the list Math.max( 0.1, 2.3, 12.7 ) is 12.7 Math.max( -2.3, -12.7 ) is -2.3 Math.min(x,y,. .) smallest value in the list Math.min( 2.3, 12.7 ) is 2.3 Math.min( -2.3, -12.7 ) is -12.7 Question: What are the values returned by: Math.floor(0) Math.floor(9.9999999)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Date Object (Handle date a nd time) (A) Creation of Date Objects To handle date and time, we need to create a Date object like: va r d=ne w Da te (. .); new Date() current date and time new Date(milliseconds)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

8FuncObjIII - The Math Object The Math Object also provides...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online