Malhar Lathkar

Malhar Lathkar

103 Articles Published

Articles by Malhar Lathkar

Page 9 of 11

PHP sqrt() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

The sqrt() function returns the square root of a positive float number. Since square root for negative numbers is not defined, it returns NAN (Not a Number). This is one of the most commonly used mathematical functions in PHP. This function always returns a floating point number. Syntax sqrt ( float $arg ) : float Parameters Parameter Description arg A number whose square root is to be obtained Return Values PHP sqrt() function returns the square root of the given arg number. For negative numbers, ...

Read More

PHP sin() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 309 Views

The sin() function returns the sine of a given angle in radians. In trigonometry, sine of an angle is defined as the ratio of the length of the opposite side to the hypotenuse in a right triangle. sin(x) = opposite/hypotenuse For example, if x = 90 degrees (π/2 radians), sin(x) = 1, as the opposite side equals the hypotenuse in this case. This function returns a float value. Syntax sin(float $arg): float Parameters Parameter Description arg A floating point value representing the angle in radians ...

Read More

PHP round() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

The round() function proves useful in rounding any floating point number up to a desired precision level. Positive precision parameter causes the number to be rounded after decimal point, whereas with negative precision, rounding occurs before decimal point. Precision is 0 by default. For example, round(10.6) returns 11, round(10.2) returns 10. The function always returns a floating point number. Syntax round(float $value, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): float Parameters Parameter Description value A float number to be rounded precision Number of decimal digits to ...

Read More

PHP pow() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

The pow() function is used to compute the power of a certain number. It returns xy calculation, also termed as x raised to y. PHP also provides "**" as an exponentiation operator. So, pow(x, y) returns xy which is same as x**y Syntax pow ( number $base , number $exp ) : number Parameters Sr.No Parameter & Description 1 baseThe base to be raised 2 expPower to which base needs to be raised Return Value PHP pow() function returns base raised to power ...

Read More

PHP pi() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 534 Views

The pi() function returns the value of mathematical constant π (pi). It returns a float value 3.14159265359 which is equal to the predefined constant M_PI in PHP. Syntax pi() : float Parameters This function requires no parameters. Return Value The pi() function returns the mathematical constant π as a float value. This is equivalent to using the predefined constant M_PI, providing a convenient function-based alternative for mathematical calculations. Example Here's how to use the pi() function in mathematical calculations − The output of the above ...

Read More

PHP mt_srand() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 478 Views

The mt_srand() function seeds the Mersenne Twister random number generator in PHP. The prefix 'mt' stands for Mersenne Twister, which is a high−quality pseudorandom number generator algorithm. While seeding is optional in PHP (done automatically), manual seeding ensures reproducible random sequences or better randomization. Syntax mt_srand ([ int $seed [, int $mode = MT_RAND_MT19937 ]] ) : void Parameters Parameter Description seed (optional) Integer value used as seed. If omitted, a random number is used mode (optional) MT_RAND_MT19937: Uses fixed Mersenne Twister implementationMT_RAND_PHP: Uses default PHP implementation ...

Read More

PHP mt_rand() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 480 Views

The 'mt' prefix in function's name stands for Mersenne Twister. The mt_rand() function returns a random integer using the Mersenne Twister Random Number Generator algorithm. This function is a drop−in replacement for PHP's rand() function and is four times faster. The default range is between 0 and the platform−specific mt_getrandmax() value (2147483647 on 64−bit systems). Syntax mt_rand() : int mt_rand(int $min, int $max) : int Parameters Parameter Description min Lower limit of the range. Default is 0 max Upper limit of the range. Default is mt_getrandmax() ...

Read More

PHP mt_getrandmax() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 214 Views

The mt_getrandmax() function returns the largest possible integer that can be generated by the mt_rand() function. The 'mt' prefix stands for Mersenne Twister, which is the random number generator algorithm used by this function. Syntax mt_getrandmax(): int Parameters This function does not require any parameters. Return Value Returns an integer representing the maximum value that mt_rand() can generate. On most systems, this value is 2147483647 (2^31 - 1). Example Here's how to use mt_getrandmax() to get the maximum random value − Maximum random value: ...

Read More

PHP lcg_value() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 248 Views

The lcg_value() function generates a pseudo-random floating-point number between 0 and 1. LCG stands for Linear Congruential Generator, which is one of the oldest and most widely used pseudorandom number generator algorithms. Syntax lcg_value(): float Parameters This function takes no parameters. Return Value Returns a pseudo-random float value between 0.0 and 1.0 (inclusive of 0.0, exclusive of 1.0). Example Here's a basic example demonstrating the lcg_value() function ? The output will be different each time the script runs ? Random value 1: 0.45920201711279 ...

Read More

PHP is_nan() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 967 Views

The is_nan() function in PHP checks whether a given value is NaN (Not a Number). This is particularly useful when working with mathematical operations that might produce invalid results. Syntax is_nan ( float $val ) : bool Parameters Parameter Description val The floating-point value to check for NaN Return Value Returns true if the value is NaN, false otherwise. Example The following example demonstrates how is_nan() works with various mathematical operations that produce NaN ? The output of the ...

Read More
Showing 81–90 of 103 articles
« Prev 1 7 8 9 10 11 Next »
Advertisements