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实现一个限制实例化次数的类示例

本文实例讲述了PHP实现一个限制实例化次数的类。分享给大家供大家参考,具体如下: 实现思路 定义一个static变量$count,用于保存实例化对象的个数 定义一个static...

header导出Excel应用示例

复制代码 代码如下: <?php class reportFormAction extends CommonAction{ public function index(){ if(...

php中strtotime函数用法详解

本文实例讲述了php中strtotime函数用法。分享给大家供大家参考。具体如下: strtotime(字符串$时间[,诠释$现在])int strtotime(string $time...

使用XHGui来测试PHP性能的教程

使用XHGui来测试PHP性能的教程

Profiling是一项用来观察程序性能的技术,非常适用于发现程序的瓶颈或者紧张的资源。Profiling能够深入程序的内部,展现request处理过程中每一部分代码的性能;同时,也可以...

php线性表顺序存储实现代码(增删查改)

复制代码 代码如下: <?php /* *文件名:linearList.php * 功能:数据结构线性表的顺序存储实现 * author:黎锦焕 * @copyright:www....