Showing posts with label PHP Math Function for BCA. Show all posts
Showing posts with label PHP Math Function for BCA. Show all posts

Sunday, January 21, 2018

PHP Math Function for BCA,B.Sc(IT),MCA,M.Sc(IT) and IT Students


--------------------------------------------------------------------------------------------------------------------------
Prepared By    : Uday Shah (HOD-ID)
Contact No     : 7600044051
E-Mail            : rupareleducation@gmail.com


PHP Math functions

Sr.No
Name
Description
1
abs()
It returns the absolute value of number. It means it gives the positive answer.
Syntax: abs(mixed number)
Ex: abs(-4)
2
Ceil()
It returns the next highest integer value by rounding up the value.
The return value of ceil is still bigger then that of integer.
Syntax: float ceil(float value)
Ex: ceil(5.6)
3
floor()
It returns the next lowest integer value by rounding down the value.
Syntax: float floor(float value)
Ex: floor(5.6)
4
Round()
It returns the rounded value of specified precision(No. of digit) after the decimal point.
Syntax: float round(float value)
Ex: round(3.5)
5
fmod()
It returns the floating point reminder(modular) of the division of argument.
It returns the floating point reminder of dividing the dividend[x] by the divisor [y].
Syntax: float fmod(float x,float y)
Ex:
$x=8;
$y=3;
$r=fmod($x,$y);
6
Min()
It returns the numerically lowest value.
Syntax: min(value1,value2,value3)
Ex: min(5,4,3,2)
7
Max()
It returns the numerically highest value.
Syntax: max(value1,value2,value3)
Ex: max(5,4,3,2)
8
pow()
It returns the base raise to the power of expression. This function will return an integer value.
Syntax: pow(number base,exponent)
Ex: pow(2,3)
9
sqrt()
It return the square root of argument.
Syntax: sqrt(argument)
Ex: echo sqrt(25)
10
rand()
It returns a random integer value.
Syntax: rand()
Ex: echo rand()
11
acos()
The acos() function returns the arccosine of a number as a numeric value between 0 and PI radians.
Syntax
acos(x)

Example

In this example we will get the arccosine of different numbers:
<?php
echo(acos(-1)."<br>");
echo(acos(1)."<br>");
echo(acos(2))
?>
output :
3.14159265359
0
-1.
12
asin()
The asin() function returns the arcsine of a number as a numeric value between-PI/2 and PI/2 radians.

Syntax

asin(x)

Example

In this example we will get the arcsine of different numbers:
<?php
echo(asin(0) . "<br>");
echo(asin(-1) . "<br>");
echo(asin(1) . "<br>");
?>
The output of the code above will be:
0
-1.57079632679
1.57079632679
13
atan()
The atan() function returns the arctangent of a number as a numeric value between -PI/2 and PI/2 radians.

Syntax

atan(x)
Example 
The following example returns the arctangent of different numbers with the atan() function:
<?php
echo(atan(5) . "<br>");
?>
The output of the code above will be:
1.37340076695
14
sin()
The sin() function returns the sine of a number.

Syntax

sin(x)

Example

<?php
echo(sin(3) . "<br>");
?>
output
0.14112000806
15
bindec()
The bindec() function converts a binary number to a decimal number.

Syntax

bindec(binary_number)

Example

<?php
echo bindec("0011") . "<br>";
?>
output
3
16
decbin()
The decbin() function converts a decimal number to a binary number.

Syntax

decbin(dec_number)

Example

<?php
echo decbin("3")."<br>";
?>
output
11
17
hexdec() 
The hexdec() function converts a hexadecimal number to a decimal number.

Syntax

hexdec(hex_number)

Example

<?php
echo hexdec("e")."<br>";
echo hexdec("a")."<br>";
?>
The output of the code above will be:
14
10
18
dechex()
The dechex() function converts a decimal number to a hexadecimal number.

Syntax

dechex(dec_number)

Example

<?php
echo dechex("14")."<br>";
echo dechex("10")."<br>";
?>
output :
e
a
19
is_finite ()
The is_finite () function returns true if the specified value is a finite number, otherwise it returns nothing.
The value is finite if it is within the allowed range for a PHP float on this platform.

Syntax

is_finite(x)

Example

<?php
echo is_finite(2)."<br>";
echo is_finite(2000);
?>
output :
1
1
20
is_infinite ()
The is_infinite () function returns true if the specified value is an infinite number, otherwise it returns nothing.
The value is infinite if it is too big to fit into a PHP float on this platform.

Syntax

is_infinite(x)

Example

<?php
echo is_infinite(2) . "<br>";
?>
 output
1
21
log()
The log() function returns the natural logarithm (base E) of a number.

Syntax

log(x,base)

Example

<?php
echo(log(2.7183)."<br>");
echo(log(2)."<br>");
?>
output
1.00000668491
0.69314718056

22
base_convert()
The base_convert () function converts a number from one base to another.

Syntax

base_convert (number,frombase,tobase);

Example

Convert an octal number to a decimal number:
<?php
$oct = "0031";
$dec = base_convert($oct,8,10);
echo "$oct in octal is equal to $dec in decimal.";
?>
output
0031 in octal is equal to 25 in decimal.
23
deg2rad()
The deg2rad() function converts a degree to its radian number.

Syntax

deg2rad(degree number);

Example

<?php
echo deg2rad("30") . "<br>";
?>
output:
0.523598775598

24
cos()
The cos() function returns the cosine of a number.

Syntax

cos(x)

Example

In the following example we will return the cosine of different numbers:
<?php
echo(cos(3) . "<br>");
?>
output:
-0.9899924


Please share and comment it... Thank you.

:: Best Of Luck :: 

https://myshopprime.com/uday.shah3/shop