Basic HTML version of Foils prepared 23 June 1997

Foil 39 Math and Number Objects

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo

three examples using Math Object for Foil 39
1 Math has a set of properties (built-in constants) including
2 E, LN10, LN2, PI, SQRT1_2, and SQRT2. For example:
3 Math.PI is equal to 3.14159É
4 Math methods include the usual ones:
5 Math.abs(x) returns the absolute value of x
6 Math.max(x1,x2) returns the maximum of x1 and x2
7 Math.cos(x) returns the cosine of x (given in radians)
8 Math.round(x) rounds x to the nearest integer
9 Math.pow(2, 0.5) is equivalent to Math.sqrt(2)
10 The Number object has properties defining system dependent constants such as:
  • Number.MAX_VALUE is largest representable number on your machine
  • Number.NaN represents "Not a Number" sometimes returned by parseInt and parseFloat

in Table To:


Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998