HELP! * YELLOW=global GREY=local Global HTML version of Foils prepared 21 February 97

Foil 28 The Math and Number Objects in JavaScript

From Feb 17/19 Delivered Lecture for Course CPS616 -- aJavaScript Language Objects and Frames CPS616 spring 1997 -- Feb 17 and 19 1997. by Geoffrey Fox * Important Information in IMAGE
Secs 63.3 Addon
Math has a set of properties(built in constants) including
E LN10 LN2 PI SQRT1_2 SQRT2 so that
Math.PI = 3.14159 etc.
Math methods include the usual ones in Fortran Intrinsic library with examples
Math.random() returns pseudo random number between 0 and 1
Math.abs(x) returns absolute value of x
Math.max(x1,x2) returns maximum of two numbers x1 and x2
Math.cos(x) returns cosine of argument x in radians
Math.round(x) rounds x to nearest positive or negative integer
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" used 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 Fri Feb 21 1997