PHP中的float类型使用说明

yipeiwu_com6年前PHP代码库
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匿名函数与注意事项

php5.3不但引进了匿名函数还有更多更好多新的特性了,下面我们一起来了解一下PHP匿名函数与注意事项,具体内容如下 PHP5.2 以前:autoload, PDO 和 MySQLi,...

php中的常用魔术方法总结

常用的魔术方法有:__Tostring ()  __Call()  __autoLoad()  __ clone()  __GET() ...

解析curl提交GET,POST,Cookie的简单方法

复制代码 代码如下:<?php$get_data = array (    "get1"=> "get1",   ...

完美解决PHP中的Cannot modify header information 问题

完美解决PHP中的Cannot modify header information 问题

我就遇到这种问题,网上找到这个解决的方案,就收藏下写PHP的朋友们肯定遇到过这样一个问题:通过header函数改变http协议头的时候,会出现一个类似下面格式的warning:复制代码...

php生成zip压缩文件的方法详解

复制代码 代码如下:require_once "./include/zip.php"; $zip = new PHPZip(); //$zip -> createZip("要压缩的...