Use instructions for float types in PHP

  • 2020-03-31 21:01:53
  • OfStack

The representation of a float type can be as follows:
 
<?php 
$a = 1.234; 
$b = 1.2e3; 
$c = 7E-10; 
?> 

One thing to note about using PHP's float type is that the precision of PHP's float type is somewhat questionable. If high-precision mathematical calculations are required, the specialized mathematical function array (PHP) and the GMP series of functions are available. Also, don't try to compare variables of float type.

Converting to float
For information on conversion strings to float, see String conversion to Numbers. For values of other types, Conversion is performed by converting the value to integer first and then to float. See converting to integer for more information. A notice is thrown if an object is converted to float.

No translation. Ha ha

Related articles: