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中ltrim与rtrim去除左右空格及特殊字符实例

本文实例分析了PHP中ltrim与rtrim去除左右空格及特殊字符的用法。分享给大家供大家参考,具体如下: 一、PHP中ltrim定义如下: ltrim(string,charlist)...

php readfile下载大文件失败的解决方法

本文实例讲述了php readfile下载大文件失败的解决方法。分享给大家供大家参考,具体如下: 大文件有200多M,只下载了200K就提示下载完成,且不报错。 原因是PHP内存有限制,...

解析php类的注册与自动加载

解析php类的注册与自动加载

工程目录如下:1、将需要注册的类放在一个数组中复制代码 代码如下:<?phpfinal class Utils {    private functi...

php向js函数传参的几种方法

<?php echo "<script>test('$_POST[userid]');</script> "; ?> 在上面的...

详解WordPress中的头像缓存和代理中的缓存更新方法

详解WordPress中的头像缓存和代理中的缓存更新方法

wordpress评论中的头像是使用Gravatar的头像服务(Gravatar官方注册地址:http://en.gravatar.com),用户的缓存头像一般都是固定不变的,所以我们可...