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 by Malhar Lathkar
Page 10 of 11
PHP 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 MorePHP deg2rad() Function
The deg2rad() function in PHP converts angles from degrees to radians. This function is essential when working with trigonometric functions like sin(), cos(), and tan(), which require angle arguments in radians rather than degrees. Syntax deg2rad(float $number) : float Parameters Parameter Description number A float number representing angle in degrees Return Value Returns a float number representing the angle in radians. The conversion follows the formula: radians = degrees × π/180. Example Here's how to convert degrees to radians using deg2rad() − ...
Read MorePHP dechex() Function
The dechex() function converts a decimal number to its hexadecimal representation and returns it as a string. This function is particularly useful for color codes, memory addresses, and low-level programming operations. Syntax dechex ( int $number ) : string Parameters Parameter Description number A decimal number to be converted to hexadecimal representation Return Value Returns a string containing the hexadecimal representation of the given decimal number. Example 1: Basic Usage Converting positive decimal numbers to hexadecimal ? a ...
Read MorePHP decbin() Function
The decbin() function converts a decimal number to its binary representation and returns it as a string. This function is useful for displaying numbers in binary format or for bitwise operations. Syntax decbin ( int $number ) : string Parameters Parameter Description number A decimal number to be converted to binary representation Return Value Returns a string containing the binary representation of the given decimal number. Examples Basic Usage Here's how to convert positive decimal numbers to binary ? ...
Read MorePHP cos() Function
The cos() function returns the cosine ratio of given angle in radians. In trigonometry, cosine of an angle is defined as ratio of lengths of adjacent side and hypotenuse. cos(x) = adjacent/hypotenuse If x=90 degrees (π/2 radians), cos(x) = 0. This function returns a float value. Syntax cos ( float $arg ) : float Parameters Parameter Description arg A floating point value that represents angle in radians Return Value PHP cos() function returns cosine ratio of given parameter as a float. Examples ...
Read MorePHP ceil() Function
The ceil() function is a built-in mathematical function in PHP that rounds any float number up to the next highest integer. This function always returns a float number, as the range of float is larger than that of integer. Syntax ceil ( float $num ) : float Parameters Parameter Description num The number to be rounded up Return Value The ceil() function returns the smallest integer value (as float) that is greater than or equal to the given parameter. Examples Example 1: Basic Usage ...
Read MorePHP bindec() Function
The bindec() function converts a binary number represented as a string into its decimal equivalent. The binary string is interpreted as an unsigned integer, and invalid characters (other than 0 and 1) are ignored. Syntax bindec(string $binary_string): int|float Parameters Parameter Description binary_string A string containing binary digits (0 and 1). Invalid characters are ignored. Return Value Returns the decimal equivalent as an integer or float (for large numbers). Examples Basic Usage Converting a simple binary string to decimal ? ...
Read More