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管理nginx虚拟主机shell脚本实例

本文实例讲述了php管理nginx虚拟主机shell脚本,分享给大家供大家参考。具体分析如下: 使用php作为shell脚本是一件很方便的事情。理所当然,我们可以使用php脚本来管理 n...

php遍历、读取文件夹中图片并分页显示图片的方法

本文实例讲述了php遍历、读取文件夹中图片并分页显示图片的方法。分享给大家供大家参考,具体如下: 引子:我的网站图片目录images下有若干图片如1.jpg、2.jpg、3.jpg、……...

PHP实现Soap通讯的方法

本文实例讲述了PHP实现Soap通讯的方法。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下:<?php function HttpSoap($server,...

PHP下利用header()函数设置浏览器缓存的代码

这涉及到4种头标类型: Last-Modified(最后修改时间); Expires(有效期限); Pragma(编译指示); Cache-Control(缓存控制);   前三个头标属...

php使用array_search函数实现数组查找的方法

本文实例讲述了php使用array_search函数实现数组查找的方法。分享给大家供大家参考。具体实现方法如下: <?php $array = array(4,5,7,...