In PHP, numbers can be broadly categorized into two types: integers and floating-point numbers (or floats). PHP supports both decimal (base 10), hexadecimal (base 16), octal (base 8), and binary (base 2) number formats.
An integer is a whole number (without a decimal point) that can be positive, negative, or zero.
Examples:
$a = 1234; // decimal number
$b = -123; // a negative number
$c = 0x1A; // hexadecimal number (equivalent to 26 decimal)
$d = 0123; // octal number (equivalent to 83 decimal)
$e = 0b1111; // binary number (equivalent to 15 decimal)
A float (floating point number) is a number with a decimal point or a number in exponential form.
Examples:
$a = 12.345;
$b = 2.0e3; // 2000
$c = -8E-2; // -0.08
PHP provides various functions to work with numbers:
You can explicitly cast a value from one type to another:
$int = (int) 23.45; // becomes 23
$float = (float) 23; // becomes 23.0 or just 23
PHP offers several in-built constants related to numbers:
$x = acos(8); // This will return NaN because the cosine of 8 is undefined
$y = 10/0; // This will return INF
Hence we can say Numbers are fundamental to programming, and PHP offers a robust set of tools to manipulate them. Whether you're dealing with basic arithmetic, random number generation, or more advanced mathematical operations, PHP has a wide array of built-in functions to assist you.
UPCET Exam
Click Here
SAAT Exam
Click Here
MHT CET Exam
Click Here
IPU CET Exam
Click Here
KCET Exam
Click Here
COMEDK UG Exam
Click Here
VITEEE Exam
Click Here
BITSAT
Click Here
DSAT: Dayanand Sagar Admission Test
Click Here
Career In Animation in india
Click Here
Merchant Navy Courses in india
Click Here
Interior Design Career in india
Click Here
UGC NET Exam
Click Here
B. Ed Exam
Click Here
AFCAT - Air Force Common Admission Test
Click Here
GATE Exam
Click Here
Joint Entrance Examination (JEE)
Click Here
Common Admission Test (CAT)
Click Here
CDS - Combined Defence Services Exam
Click Here