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+MariaDB数据库操作基本技巧备忘总结

PHP+MariaDB数据库操作基本技巧备忘总结

本文实例总结了PHP+MariaDB数据库操作基本技巧。分享给大家供大家参考,具体如下: PHP+MySQL是比较常见的搭配,由于我主观上不太喜欢Oracle,而MySQL被它收购后,骨...

php中如何防止表单的重复提交

复制代码 代码如下:<?php/* * php中如何防止表单的重复提交 */session_start();if (empty($_SESSION['ip'])...

浅析PHP数据导出知识点

最近在做后台管理的项目,后台通常有数据导出到 excel 的需要,经过之前搜索通常推荐使用的是 php excel ,我经常使用的是 laravel ,对于 php excel 也有很好...

php自定义函数br2nl实现将html中br换行符转换为文本输入中换行符的方法【与函数nl2br功能相反】

本文实例讲述了php自定义函数br2nl实现将html中br换行符转换为文本输入中换行符的方法。分享给大家供大家参考,具体如下: 下面这几个方法将能够帮你解决这个问题。 PHP版将htm...

解析PHP中常见的mongodb查询操作

复制代码 代码如下:<?php// 欄位字串為$querys = array("name"=>"shian");// 數值等於多少$querys = array("numbe...