JavaScript Math Object
Math Object
The Math object allows you to perform mathematical tasks.
Syntax
var pi_value=Math.PI;
var sqrt_value=Math.sqrt(16);
|
Note: Math is not a constructor. All properties and methods of Math can be called by using Math as an object without creating it.
Math Object Properties
F: Firefox, IE: Internet Explorer
| Property |
Description |
F |
IE |
| E |
Returns Euler's number (approx. 2.718) |
1 |
3 |
| LN2 |
Returns the natural logarithm of 2 (approx. 0.693) |
1 |
3 |
| LN10 |
Returns the natural logarithm of 10 (approx. 2.302) |
1 |
3 |
| LOG2E |
Returns the base-2 logarithm of E (approx. 1.442) |
1 |
3 |
| LOG10E |
Returns the base-10 logarithm of E (approx. 0.434) |
1 |
3 |
| PI |
Returns PI (approx. 3.14159) |
1 |
3 |
| SQRT1_2 |
Returns the square root of 1/2 (approx. 0.707) |
1 |
3 |
| SQRT2 |
Returns the square root of 2 (approx. 1.414) |
1 |
3 |
Math Object Methods
| Method |
Description |
F |
IE |
| abs(x) |
Returns the absolute value of a number |
1 |
3 |
| acos(x) |
Returns the arccosine of a number |
1 |
3 |
| asin(x) |
Returns the arcsine of a number |
1 |
3 |
| atan(x) |
Returns the arctangent of x as a numeric value between
-PI/2 and PI/2 radians |
1 |
3 |
| atan2(y,x) |
Returns the angle theta of an (x,y) point as a numeric
value between -PI and PI radians |
1 |
3 |
| ceil(x) |
Returns the value of a number rounded upwards to the
nearest integer |
1 |
3 |
| cos(x) |
Returns the cosine of a number |
1 |
3 |
| exp(x) |
Returns the value of Ex |
1 |
3 |
| floor(x) |
Returns the value of a number rounded downwards to the
nearest integer |
1 |
3 |
| log(x) |
Returns the natural logarithm (base E) of a number |
1 |
3 |
| max(x,y) |
Returns the number with the highest value of x and y |
1 |
3 |
| min(x,y) |
Returns the number with the lowest value of x and y |
1 |
3 |
| pow(x,y) |
Returns the value of x to the power of y |
1 |
3 |
| random() |
Returns a random number between 0 and 1 |
1 |
3 |
| round(x) |
Rounds a number to the nearest integer |
1 |
3 |
| sin(x) |
Returns the sine of a number |
1 |
3 |
| sqrt(x) |
Returns the square root of a number |
1 |
3 |
| tan(x) |
Returns the tangent of an angle |
1 |
3 |
| toSource() |
Represents the source code of an object |
1 |
- |
| valueOf() |
Returns the primitive value of a Math object |
1 |
4 |
Make your web applications look like a million bucks
|
|
Most web applications today use boring methods to present data to their viewers using grids or simple HTML tables. FusionCharts induces "life" into the web applications by converting monotonous data into lively charts, gauges & maps.
FusionCharts works with all technologies like ASP, ASP.NET, PHP, ColdFusion, Ruby on Rails, JSP, HTML pages etc.
and connects to any database to render animated & interactive charts. It takes less than 15 minutes and no expertise
whatsoever to build your first chart and just a glance of it to captivate your audience. This fact is endorsed by our
12,000 customers and 150,000 users which include a majority of the Fortune 500 companies.
And yeah, your applications could look like a million bucks by spending just $69.
So go ahead, download your
copy of FusionCharts and start "wow-ing" your customers now!
|
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4000 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|