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页面消耗内存过大的处理办法

解决办法: 1,修改 php.ini将memory_limit由 8M 改成 16M(或更大),重启apache服务 2,在PHP 文件中 加入 ini_set(”memory_limi...

PHP消息队列用法实例分析

本文实例讲述了PHP消息队列用法。分享给大家供大家参考,具体如下: 该消息队列用于linux下,进程通信 #根据路径和后缀创建一个id $key = ftok(__DIR__, 'R...

php5新改动之短标记启用方法

第一是按PHP的标准写法.<?php.....?> 第二是在配置文件中(php.ini)修改short_open_tag的值为on....

解析php addslashes()与addclashes()函数的区别和比较

PHP addcslashes() 函数定义和用法addcslashes() 函数在指定的字符前添加反斜杠。语法addcslashes(string,characters)参数 描述 s...

PHP中抽象类和抽象方法概念与用法分析

PHP中抽象类和抽象方法概念与用法分析

本文实例讲述了PHP中抽象类和抽象方法。分享给大家供大家参考,具体如下: 一、抽象关键字 :abstract 抽象就是无法确切的说明,但又有一定的概念或者名称,在PHP中声明一个抽象类或...