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
Programming Articles
Page 1077 of 2547
pi() function in PHP
The pi() function returns the value of Pi (π), which is approximately 3.1415926535898. This mathematical constant represents the ratio of a circle's circumference to its diameter. Syntax pi() Parameters The pi() function takes no parameters. Return Value Returns the approximate value of PI as a floating-point number: 3.1415926535898. Example Here's a basic example using the pi() function − 3.1415926535898 Using M_PI Constant PHP also provides the M_PI predefined constant as an alternative to the pi() function − ...
Read Moreoctdec() function in PHP
The octdec() function converts an octal number to its decimal equivalent. This function is useful when working with octal representations in PHP. Syntax octdec(octal_string) Parameters octal_string − A string containing the octal number to convert. Can include negative sign for negative numbers. Return Value The octdec() function returns the decimal equivalent of the specified octal number as an integer. Example 1: Basic Octal to Decimal Conversion Here's how to convert a simple octal number to decimal − 80 120 Example ...
Read Moremt_srand() function in PHP
The mt_srand() function seeds the Mersenne Twister random number generator in PHP. This function allows you to initialize the random number generator with a specific seed value, ensuring reproducible random number sequences. Note − Random number generator is seeded automatically after the release of PHP 4.2.0. This function is not needed now unless you want predictable random sequences. Syntax mt_srand(seed) Parameters seed − Optional integer value used to initialize the random number generator. If omitted, a random seed is used. Return Value The mt_srand() function ...
Read Moremin() function in PHP
The min() function in PHP returns the minimum value from a given set of values or an array. It compares all provided values and returns the smallest one. Syntax min(arr_values); or min(val1, val2, ...); Parameters arr_values − An array containing the values to compare. val1, val2, ... − Individual values to compare (can pass multiple arguments). Return Value Returns the minimum value from the provided arguments or array. The return type matches the type of the smallest value. Example 1: Using ...
Read Moremax() function in PHP
The max() function in PHP returns the maximum value from a set of values or an array. It accepts either multiple individual values or a single array as input. Syntax max(value1, value2, value3, ...) max(array_values) Parameters value1, value2, ... − Individual values to compare (can be numbers or strings). array_values − An array containing values to compare. Return Value Returns the maximum value found. For string comparisons, it uses lexicographical ordering. Example 1: Using Multiple Values Finding the maximum among individual numeric values − ...
Read Morelog1p() function in PHP
The log1p() function in PHP returns log(1+number), computed in a way that is accurate even when the value of number is close to zero. This function is particularly useful for mathematical calculations involving logarithms of values near zero, where direct calculation of log(1+x) might lose precision. Syntax log1p(number) Parameters number − The numeric value to be processed. Must be greater than -1. Return Value Returns the natural logarithm of (1 + number) as a float. If the number is less than or equal to -1, the function returns NAN (Not ...
Read Morelog() function in PHP
The log() function in PHP calculates the natural logarithm (base e) of a number. It can also calculate logarithms with a specified base when provided as the second parameter. Syntax log(number, base) Parameters number − The value for which you want to calculate the logarithm (must be positive) base − Optional. The logarithmic base. If omitted, calculates natural logarithm (base e) Return Value Returns the logarithm of the number. Returns -INF for zero, NAN for negative numbers, and a float value for positive numbers. Examples Basic Natural Logarithm ...
Read Moreis_nan() function in PHP
The is_nan() function checks for 'not a number' value. It returns TRUE if the value is 'not a number', else FALSE is returned. Syntax is_nan(num) Parameters num − The value to check Return Value The is_nan() function returns TRUE if num is 'not a number', else FALSE is returned. Example 1 Here's a simple example checking if a number is NaN − false Example 2 Let us see another example with acos() function − ...
Read Moreis_infinite() function in PHP
The is_infinite() function checks if a value is infinite or not. It returns true if the number is an infinite number, else it returns false. Syntax is_infinite(num) Parameters num − The number to be checked. Return Value The is_infinite() function returns true if num is an infinite number, else it returns false. Example 1: Finite Number Let's check if a regular number is infinite ? false Example 2: Infinite Number Here we use log(0) which produces negative infinity ? ...
Read Moreis_finite() function in PHP
The is_finite() function checks if a value is finite or not. It returns true if the number is a finite number, else it returns false. Syntax is_finite(num) Parameters num − The number to be checked. Return Value The is_finite() function returns true if num is a finite number, else it returns false. Example 1: Finite Number Let's check if a regular number is finite ? true Example 2: Infinite Value Let's check if log(0) (which is negative infinity) is ...
Read More