PHP Math

PHP

PHP Math, जैसे की नाम ही आप समझ गए होंगे, इसका इस्तेमाल किसी भी mathematical operations के लिए किया जाता है।

PHP कई पूर्वनिर्धारित गणित स्थिरांक (math constants) और functions प्रदान करता है जो की किसी भी mathematical operations करने की अनुमति देते हैं। जैसे की किस numbers की elementary exponential, logarithm, square root निकालना और भी कई function.

कुछ PHP Math के उदाहरण नीचे दिए गए हैं:
  • max(x,y) : इसका इस्तेमाल x और y में से highest वैल्यू धुंडने के लिए किया जाता है।
  • min(x,y) : इसका इस्तेमाल x और y में से lowest वैल्यू धुंडने के लिए किया जाता है।
  • sqrt(x)  : इसका इस्तेमाल x का square root निकालने के लिए किया जाता है।
  • abs(x)    : इसका इस्तेमाल x की positive वैल्यू को दर्शानेके लिए किया जाता है।
Example:1 PHP Math
<?php
$x = 64;
$y = 75;

echo (max($x, $y)); //Result: 75
echo "<br>";

echo (min($x, $y)); //Result: 64
echo "<br>";

echo (sqrt($y)); //Result: 8
echo "<br>";

echo (abs($x - $y)); //Result: 11
?>
Example:2 PHP Math
<?php
echo (max(54, 15, 356)); //Result: 356
echo "<br>";

echo (min(54, 15, 356)); //Result: 15
echo "<br>";

echo (sqrt(16)); //Result: 4
echo "<br>";

echo (abs(5 - 15)); //Result: 10
?>

PHP Math function की सूची

सभी PHP Math functions की एक सूची नीचे दी गई है। PHP Math function के सम्पूर्ण reference के लिए आप PHP की Official site भी जा सकते हैं।

Function Description
abs() It is used to find the absolute (positive) value of a number.
sin() It is used to return the sine of a number.
sinh() It is used to return the hyperbolic sine of a number.
asin() It is used to find the arc sine of a number.
asinh() It is used to find the inverse hyperbolic sine of a number.
cos() It is used to find the cosine of a number.
cosh() It is used to return the cosh of a number.
acos() It is used to return the arc cosine of a number.
acosh() It is used to return the inverse hyperbolic cosine of a number.
tan() It is used to return the tangent of a number.
tanh() It is used to return the hyperbolic tangent of a number.
atan() It is used to return the arc tangent of a number in radians.
atan2() It is used to return the arc tangent of two variables x and y.
atanh() It is used to return the inverse hyperbolic tangent of a number.
base_convert() It is used to convert a number from one number base to another.
bindec() It is used to convert a binary number to a decimal number.
ceil() It is used to find round a number up to the nearest integer.
pi() It returns the approximation value of PI.
decbin() It converts a decimal number to a binary number.
dechex() It converts a decimal number to a hexadecimal number.
decoct() It converts a decimal number to an octal number
deg2rad() It converts a degree value to a radian value.
rad2deg() It converts a radian value to a degree value.
exp() It is used to calculate the exponent of e.
expm1() It is used to return exp(x) - 1.
floor() It converts round a number down to the nearest integer.
fmod() It returns the remainder of x/y.
getrandmax() It returns the largest possible value returned by rand().
hexadec() It is used to convert a hexadecimal number to a decimal number.
hypot() It is used to calculate the hypotenuse of a right-angle triangle.
is_finite() To check whether a value is finite or not.
is_infinite() It is used to check whether a value is infinite or not.
is_nan() It is used to check whether a value is 'not-a-number'.
lcg_value() It is used to return a pseudo random number in a range between 0 and 1.
log() It is used to return the natural logarithm of a number.
log10() It is used to return the base-10 logarithm of a number.
log1p() It is used to return log(1+number).
max() It is used to return the highest value in an array, or the highest value of several specified values.
min() It returns the lowest value in an array, or the lowest value of several specified values.
getrandmax() It is used to return the maximum value by using rand().
mt_getrandmax() Returns the largest possible value returned by mt_rand().
mt_rand() Generates a random integer using Mersenne Twister algorithm.
mt_srand() Seeds the Mersenne Twister random number generator.
octdec() It is used to converts an octal number to a decimal number.
pow() It is used to return x raised to the power of y.
intdiv It returns the integer quotient of the division of dividend by divisor.
rand() It is used to generates a random integer.
round() It is used to round a floating-point number.
fmod() It is used to return the floating point remainder of the division of the argument.
sqrt() It is used to return the square root of a number.
Article By: Brajlal Prasad
Created on: 16 Feb 2023  1287  Views
 Print Article
Report Error

If you want to report an error, or any suggestion please send us an email to [email protected]