8FuncObjIII

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

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

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)

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

View Full Document
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)
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 03/10/2012 for the course CS 1301 taught by Professor Dr.wong during the Winter '08 term at City University of Hong Kong.

### 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
Ask a homework question - tutors are online