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的HTTP客户端Guzzle简单使用方法分析

PHP的HTTP客户端Guzzle简单使用方法分析

本文实例讲述了PHP的HTTP客户端Guzzle简单使用方法。分享给大家供大家参考,具体如下: 首先来一段官方文档对Guzzle的介绍: 然后cd到网站根目录,执行Composer命令...

php实现的一段简单概率相关代码

本文实例讲述了php实现的一段简单概率相关代码。分享给大家供大家参考,具体如下: <?php for($i=1;$i<100000;$i++){ $x=mt_ra...

Mac系统下安装PHP Xdebug

Mac系统下安装PHP Xdebug

Mac下安装PHP调试工具Xdebug 安装步骤 brew install php70 brew install php70-xdebug php -i | grep...

php算开始时间到过期时间的相隔的天数

复制代码 代码如下://mktime = mktime($hours,minute,seconds,month,day,years) $start_time = mktime(0,0,0...

php实现删除指定目录下相关文件的方法

本文实例讲述了php实现删除指定目录下相关文件的方法。分享给大家供大家参考。具体实现方法如下: 通常来说在php中删除文件最简单的方法就是直接使用unlink命令,而对于需要删除指定目录...