Tutorialspoint examples

Learn java tutorial with examples for beginners online

TypeScript math object tutorial

TypeScript math object:

A TypeScript Math object provides no. of properties and methods for performing mathematical operations. Math is not a constructor and all the properties and methods of Math are static.

TypeScript Math Object Properties:

Property Description
E \ Euler’s constant and the base of natural logarithms, approximately 2.718.
LN2 Natural logarithm of 2, approximately 0.693.
LN10 Natural logarithm of 10, approximately 2.302.
LOG2E Base 2 logarithm of E, approximately 1.442.
LOG10E Base 10 logarithm of E, approximately 0.434.
PI Ratio of the circumference of a circle to its diameter, approximately 3.14159.
SQRT1_2 Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.
SQRT2 Square root of 2, approximately 1.414.

TypeScript Math Object Methods:

Method Description
abs() It returns the absolute value of a number.
acos() It returns the arccosine (in radians) of a number.
asin() It returns the arcsine (in radians) of a number.
atan() It returns the arctangent (in radians) of a number.
atan2() It returns the arctangent of the quotient of its arguments.
ceil() It returns the smallest integer greater than or equal to a number.
cos() It returns the cosine of a number.
exp() It returns EN, where N is the argument, and E is Euler’s constant, the base of the natural logarithm.
floor() It returns the largest integer less than or equal to a number.
log() It returns the natural logarithm (base E) of a number.
max() It returns the largest of zero or more numbers.
min() It returns the smallest of zero or more numbers.
pow() It returns base to the exponent power, that is, base exponent.
random() It returns a pseudo-random number between 0 and 1.
round() It returns the value of a number rounded to the nearest integer.
sin() It returns the sine of a number.
sqrt() It returns the square root of a number.
tan() It returns the tangent of a number.
toSource() It returns the string “Math”.


function mathTest(num:number):void{
  var squarRoot = Math.sqrt(num);
  console.log("Random Number:  " + num); 
  console.log("Square root:  " + squarRoot); 
var num:number = Math.random();

Try it:

JS Bin on jsbin.com

TypeScript Tutorial

TypeScript Overview.
Typescript vs Javascript.
Typescript let vs var.
TypeScript Hello World.
Typescript Data Types.
Typescript Variable Declaration.
TypeScript operators list.
TypeScript Arithmetic Operators.
TypeScript Comparison Operators.
TypeScript Bitwise Operators.
Typescript Logical Operators.
TypeScript Assignment Operators.
Typescript Conditional Operator.
Typescript String Operator.
Typescript typeof Operator.
TypeScript control statements.
TypeScript Switch Statement.
TypeScript for loop.
TypeScript for in loop.
TypeScript while loop.
TypeScript do while loop.
Typescript for loop break.
TypeScript for loop continue.
Typescript function.
Typescript returning function.
Typescript parameterized function.
Typescript function optional parameter.
Typescript rest parameters.
Typescript default parameters.
Typescript anonymous function.
Typescript function constructor.
Typescript Arrow/Lambda function.
Typescript function overloading.
TypeScript number object.
TypeScript string object.
TypeScript boolean object.
TypeScript date object.
TypeScript math object.
TypeScript array object.
TypeScript tuples.
TypeScript union type.
TypeScript interface.
TypeScript interface inheritance.
TypeScript interface multiple inheritance.
TypeScript class.
Typescript class inheritance.
Typescript class interface.
TypeScript abstract class.
TypeScript object.
TypeScript duck typing.
TypeScript NameSpace.
TypeScript Multi-file namespaces.
TypeScript module.
TypeScript ambient module.
Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status