LESS - Math Functions



Description

Math functions includes methods which are used for performing numeric operations such as round, square root, power value, modulus, percentage, etc.

Following table shows Math Functions used in LESS −

Sr.No. Function & Description Example
1

ceil

It rounds up the number to next highest integer.

ceil(0.7)

it round the number to −

1
2

floor

It rounds down the number to next lowest integer.

floor(3.3)

it round the number to −

3
3

percentage

It transforms the floating point number to percentage string.

percentage(0.2)

it converts the number to percentage string as −

20%
4

round

It rounds a floating point number.

round(3.77)

it converts the number to the rounding value as −

4
5

sqrt

It returns the square root of a number.

sqrt(25)

it defines the square root of a number as −

5
6

abs

It provides the absolute value of a number.

abs(30ft)

it displays the absolute value as −

30ft
7

sin

It returns radians on numbers.

sin(2)

it calculates the sine value as −

0.90929742682
8

asin

It specifies arcsine (inverse of sine) of a number which returns value between -pi/2 and pi/2.

asin(1)

it calculates the asin value as −

1.5707963267948966
9

cos

It returns cosine of the specified value and determines radians on numbers without units.

cos(2)

it calculates the cos value as −

-0.4161468365471424
10

acos

It specifies arccosine (inverse of cosine) of a number which returns value between 0 and pi.

acos(1)

it calculates the acos value as −

0
11

tan

It specifies tangent of the number.

tan(60)

it calculates the tan value as −

0.320040389379563
12

atan

It specifies arctangent (inverse of tangent) of a specified number.

atan(1)

it displays atan value as −

0.7853981633974483
13

pi

It returns the pi value.

pi()

it determines the pi value as −

3.141592653589793
14

pow

It specifies the value of first argument raised to the power of second argument.

pow(3,3)

it specifies the power value as −

27
15

mod

It returns modulus of first argument with respect to the second argument. It also handles negative and floating point numbers.

mod(7,3)

it returns the modulus value as −

1
16

min

It specifies the smallest value of one or more arguments.

min(70,30,45,20)

it returns the minimum value as −

20
17

max

It specifies the highest value of one or more arguments.

max(70,30,45,20)

it returns the maximum value as −

70
Advertisements