PHP中的float类型使用说明

yipeiwu_com5年前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 mb_substr()函数截取中文字符串应用示例

substr()函数用来截取字符串,但是对于中文字符会出现问题,而mb_substr()和mb_strcut这两个函数可以,用法与substr()相似,只是在函数最后要加入多一个参数,以...

PHP连接sql server 2005环境配置及问题解决

一、Windows下PHP连接SQLServer 2005 设定:安装的Windows操作系统(Win7 或XP均可,其他系统暂未测试),在C盘下;PHP的相关文件位于c:/PHP下面,...

asp.net访问网络路径方法(模拟用户登录)

核心代码: public class IdentityScope : IDisposable { // obtains user token [DllImport("...

PHP文件上传类实例详解

本文实例讲述了PHP文件上传类。分享给大家供大家参考,具体如下: 这里演示了FileUpload.class.php文件上传类,其中用到了两个常量,可在网站配置文件中定义: defi...

PHP自定义函数判断是否为Get、Post及Ajax提交的方法

本文实例讲述了PHP自定义函数判断是否为Get、Post及Ajax提交的方法。分享给大家供大家参考,具体如下: /** * 是否是AJAx提交的 * @return bool...