Real Numbers¶
Real numbers are represented using the float data type.
They are also commonly referred to as floating-point numbers or double-precision numbers. Floats are used to represent decimal numbers, including both whole numbers and fractions, with a certain degree of precision. Real numbers are used for performing mathematical calculations that require decimal accuracy.
There used to be real dedicated structures in PHP, like is_real() or (real), though, they were removed in PHP 7.0. In case of doubt, refer to float.
It’s important to be aware of potential rounding errors or precision issues when working with real numbers. in PHP or any other programming language that uses floating-point representation. If exact decimal precision, it is recommended to use specialized libraries or techniques to handle arbitrary precision arithmetic, such as bcmath or gmp.
<?php
$a = 1.234;
?>
See also How To Work with Numbers in PHP.
Related : Floating Point Numbers, Bcmath, GNU Multiple Precision (GMP), Rounding