OLPCities/Math (JavaScript)

From OLPC

< OLPCities
Revision as of 23:41, 13 February 2007 by Jacobolus (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

"Math" is a Class that is part of the generic JavaScript API. This "library" is referenced automaticaly by the browser of the OLPC station and you don't need to add anything in the program to use it.

In this Class you will not need to create an object, a prefix. The object is always : Math.

Using this Math prefix, the methods of the class are:

Methods

Math.abs(number)            Returns the absolute value of number. 

Math.ceil(number)           Returns the next largest  integer 
                            greater than number (rounds up).

Math.floor(number)          Returns the next smallest  integer 
                            less than the number (rounds down).

Math.pow(num1, num2)        Returns the value of num1 to the 
                            power of num2.

Math.random()               Returns a number between 0 and 1.

Math.round(number)          Returns the closest integer to the 
                            number

Math.sqrt(number)           Returns the square root of the number        
Personal tools
  • Log in
  • Login with OpenID
About OLPC
About the laptop
About the tablet
Projects
OLPC wiki
Toolbox