float 类型的表示可以有以下几种:
代码如下:
- $a = 1.234;
- $b = 1.2e3;
- $c = 7E-10;
- ?>
使用 PHP 的 float 类型需要注意的是: PHP 的 float 类型的精度有点问题如果需要高精度的数学计算, 可以使用 php 提供的专用的数学函数 arbitrary precision math functions 系列和 gmp 系列函数还有就是不要试图进行比较 float 类型的变量
- Converting to float
- For information on converting strings to float, see String conversion to numbers. For values of other types, the conversion is performed by converting the value to integer first and then to float. See Converting to integer for more information. As of PHP 5, a notice is thrown if an object is converted to float.
不翻译了呵呵
来源: https://www.php1.cn/detail/php-dca29ff95b.html