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.

不翻译了。呵呵

相关文章

php5.3 不支持 session_register() 此函数已启用的解决方法

php从5.2.x升级到5.3.2.出来问题了。有些原来能用的程序报错了。报错内容是Deprecated: Function session_register() is deprecat...

PHP实现限制IP访问及提交次数的方法详解

本文实例讲述了PHP实现限制IP访问及提交次数的方法。分享给大家供大家参考,具体如下: 一、原理 提交次数是肯定要往数据库里写次数这个数据的,比如用户登陆,当用户出错时就忘数据库写入出错...

巧用php中的array_filter()函数去掉多维空值的代码分享

其实我们可以利用array_filter函数轻松去掉多维空值,而数组的下标没有改变,下面是举例用法: <?php $array = array( 0 => '滔哥', 1 =...

PHP实现通过Luhn算法校验信用卡卡号是否有效

本文实例讲述了PHP实现通过Luhn算法校验信用卡卡号是否有效的方法。分享给大家供大家参考。具体实现方法如下: $numbers = "49927398716 49927398717...

PHP使用JpGraph绘制折线图操作示例【附源码下载】

PHP使用JpGraph绘制折线图操作示例【附源码下载】

本文实例讲述了PHP使用JpGraph绘制折线图操作。分享给大家供大家参考,具体如下: 下载jpgraph类库,使用的是src目录下的类文件。 require_once './src...