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
Math has a set of properties (built-in constants) including
E, LN10, LN2, PI, SQRT1_2, and SQRT2. For example:
Math.PI is equal to 3.14159É
Math methods include the usual ones:
Math.abs(x) returns the absolute value of x
Math.max(x1,x2) returns the maximum of x1 and x2
Math.cos(x) returns the cosine of x (given in radians)
Math.round(x) rounds x to the nearest integer
Math.pow(2, 0.5) is equivalent to Math.sqrt(2)
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



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