Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PHP Expert

Predefined Objects

Let us assume some of the most frequently utilized predefined objects provided in Javascript.

Math object

In most of the applications we have to perform calculations, whether this is accounting software or scientific software. Programmers are frequently typecast as good mathematicians. Every mathematician required a calculator sometimes, or in the particular case of JavaScript, the Math object. If we desire to calculate "2.5 to the power of 8" or "Sin0.9" in your script, then JavaScript's virtual calculator is what you desire. The Math object have a number of manipulating functions:

The Math object

Methods

Description

Math.abs(x)

Return absolute value of x

Math.acos(x)

Return arc cosine of x in radians

Math.asin(x)

Return arc sine of x in radians

Math.atan(x)

Return arc tan of x in radians

Math.atan2(x, y)

Counterclockwise angle among x axis & point (x,y)

Math.ceil(x)

Rounds a number up

Math.cos(x)

Trigonometric cosine of x (x in radians)

Math.exp(x)

Exponential method ex

Math.floor(x)

Rounds number down

Math.log(x)

Natural logarithm of x (base e)

Math.max(a, b)

Returns the larger of two values

Math.min(a, b)

Returns the smaller of two values

Math.pow(x, y)

Returns xy

Math.round(x)

Rounds x to the closest integer

Math.sin(x)

Trigonometric sine of x (x in radians)

Math.sqrt(x)

Square root of x

Math.tan(x)

Trigonometric tangent of x (x in radians)

Properties

Description

Math.E

Euler's constant ( ~ 2.718)

Math.LN10

Natural logarithm of 10 (~ 2.302)

Math.LN2

Natural logarithm of 2 (~ 0.693)

Math.LOG10E

Base 10 logarithm of Euler's constant (~          0.0434)

Math.LOG2E

Base 2 logarithm of Euler's constant (~1.442)

Math.PI

The ratio of a circle's circumference to its   diameter

(~3.141)

Math.SQRT1_2

Square root of 0.5 ( ~ 0.707)

Math.SQRT2

Square root of 2.0 ( ~ 1.414)

 

Let us encompass Javascript perform some mathematical calculations: 

  //calculate e                                                                                                                                    

Math.exp(5)                                                                                                                                       

//calculate cos(2PI)

Math.cos(2*Math.PI)                                                                                                                        

The "with" statement

If you intend to invoke Math multiple times in your script, a good statement to remember is "with." Using it you can omit the "Math." prefix for any subsequent Math properties/methods:

with (Math){ var x= sin(3.5) var y=tan(5)

var result=max(x,y)

}

PHP , Programming

  • Category:- PHP
  • Reference No.:- M9622064

Have any Question?


Related Questions in PHP

Final project assignment -requirements specifications -1

FINAL PROJECT ASSIGNMENT - REQUIREMENTS / SPECIFICATIONS - 1. For the final project, you will have to make good use of your CMS using PHP and MySQL for the content delivery. You will have to be able to deliver the conten ...

Question develop a 5-6 page word document that describes

Question: Develop a 5-6 page Word document that describes the design for a small Web site that meets the following specifications. 1. The Web site includes four or more Web pages designed according to current usability g ...

Question using the course software and week one template as

Question: Using the course software and Week One Template as a starting point, create a new HTML webpage and include the following: • Write the code to display your name in the largest-size heading element. • Write the m ...

Question continue to build on the skills of providing web

Question: Continue to build on the skills of providing Web page content and structure with HTML and Web page style and layout using CSS. Demonstrate the skill of creating a dynamic Web page that includes JavaScript clien ...

In php write a simple addtion calculator that reads in two

In PHP write a simple addtion calculator that reads in two values and then add them together and display the output. Be sure to validate both inputs and ensure that it can add 0+0 = Sum: 0. The user should be able to inp ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As