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.

不翻译了。呵呵

相关文章

ubuntu下编译安装xcache for php5.3 的具体操作步骤

wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gzsudo tar -xzvf  xc...

php从csv文件读取数据并输出到网页的方法

本文实例讲述了php从csv文件读取数据并输出到网页的方法。分享给大家供大家参考。具体实现方法如下: <?php $fp = fopen('sample.csv','r...

粗略计算在线时间,bug:ip相同

<?PHP /* CREATE TABLE `db_online` (   `ip` char(20) def...

PHP中散列密码的安全性分析

本文实例讲述了PHP中散列密码的安全性。分享给大家供大家参考,具体如下: php的基本哈希函数已经不再安全? php手册中有专门的一个部分来介绍这个问题 http://php.net/m...

PHP中$GLOBALS与global的区别详解

PHP中$GLOBALS和global都可以实现全局变量的功能,所以很多人都认为global和$GLOBALS[]只是写法上面的差别,其实不然。$GLOBALS 是一个超级全局变量,其实...