PHP中的float类型使用说明
更新时间:2010年07月27日 19:41:04 作者:
使用PHP的float类型需要注意的是:PHP的float类型的精度有点问题。如果需要高精度的数学计算,可以使用php提供的专用的数学函数 arbitrary precision math functions系列和gmp系列函数。
float类型的表示可以有以下几种:
<?php
$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.
不翻译了。呵呵
复制代码 代码如下:
<?php
$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.
不翻译了。呵呵
相关文章
探讨PHP函数ip2long转换IP时数值太大产生负数的解决方法
本篇文章是对PHP函数ip2long转换IP时数值太大产生负数的解决方法进行了详细的分析介绍,需要的朋友参考下2013-06-06
PHP中file_exists()判断中文文件名无效的解决方法
这篇文章主要介绍了PHP中file_exists()判断中文文件名无效的解决方法,是很多PHP开发人员都会遇到的问题,主要涉及对编码的转换,需要的朋友可以参考下2014-11-11


最新评论