Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
PHP pi() Function
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 MorePHP mt_srand() Function
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 MorePHP mt_rand() Function
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 MorePHP mt_getrandmax() Function
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 MorePHP lcg_value() Function
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 MorePHP is_nan() Function
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 MorePHP hexdec() Function
The hexdec() function converts a hexadecimal string to its decimal equivalent. This function is useful when working with color codes, memory addresses, or any data represented in hexadecimal format. Syntax hexdec(string $hex_string): int|float Parameters Parameter Description hex_string The hexadecimal string to convert. Can include optional 0x prefix Return Value Returns the decimal representation as an integer or float. Large values may return as float due to integer overflow. Examples Basic Hexadecimal Conversion Converting common hexadecimal values to decimal ?
Read MorePHP getrandmax() Function
The getrandmax() function returns the largest possible integer that can be used by the rand() function in PHP. This value represents the upper limit for random number generation and is platform-dependent. Syntax getrandmax(): int Parameters This function takes no parameters. Return Value Returns the largest possible integer value that rand() can generate. On most 64-bit systems, this is typically 2147483647. Example Here's how to use getrandmax() to check the maximum random value ? Largest possible random integer: 2147483647 Random number between 0 and max: ...
Read MorePHP floor() Function
The floor() function is a built-in PHP function that accepts any float number as argument and rounds it down to the next lowest integer. This function always returns a float number as the range of float is bigger than that of integer. Syntax floor ( float $num ) : float Parameters Parameter Description num The number to be rounded down Return Value The floor() function returns the largest integer less than or equal to the given parameter as a float value. Examples Basic Usage ...
Read MorePHP expm1() Function
The expm1() function calculates ex - 1 in a numerically stable way. It provides better precision than manually computing exp(x) - 1, especially when the value of x is close to zero. Syntax expm1(float $arg) : float Parameters Parameter Description arg A floating point number whose expm1 value is to be calculated Return Value Returns earg - 1 as a floating point number. Examples Basic Usage Here's a simple example demonstrating the expm1() function − expm1(1) = ...
Read More