Section 24.123. Math.sqrt( ): compute a square root


24.123. Math.sqrt( ): compute a square root

ECMAScript v1

24.123.1. Synopsis

 Math.sqrt(x) 

24.123.1.1. Arguments

x

A numeric value greater than or equal to zero.

24.123.1.2. Returns

The square root of x. Returns NaN if x is less than zero.

24.123.2. Description

Math.sqrt( ) computes the square root of a number. Note, however, that you can compute arbitrary roots of a number with Math.pow( ). For example:

 Math.cuberoot = function(x){ return Math.pow(x,1/3); } Math.cuberoot(8);  // Returns 2 




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net