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中spl_autoload详解

SPL有两个不同的函数 spl_autoload, spl_autoload_call,通过将autoload_func指向这两个不同的函数地址来实现不同的自动加载机制。 spl_aut...

Drupal7 form表单二次开发要点与实例

请记得收藏此文,在你进行Drupal 7 custom module时,经常会用到的form 表单的跳转或重载。主要汇总三个要点: 1.页面提交后,经过#submit处理后,需要redi...

php 上一篇,下一篇文章实现代码与原理说明

实现原理: 就是对id对进行order by id desc 或 order by id asc进行排序,然后再判断比当前id> or小于当前文章id的相同栏目的文章。 实例的sq...

Php output buffering缓存及程序缓存深入解析

Php output buffering缓存及程序缓存深入解析

下面测试ob缓存和程序缓存:在测试前为了测试效果更明显,我们在php.ini里先关闭ob缓存并设置明显的错误级别。Output_buffering=offDisplay_errors=o...

PHP 数据结构 算法 三元组 Triplet

复制代码 代码如下: <?php /** * 三元组 Triplet * */ class Triplet { private $_data = null; // 初始化三元组 p...