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利用Socket获取网站的SSL证书与公钥

通过 php curl 请求网页并不能获取到证书信息,此时需要使用 ssl socket 获取证书内容。下面来一起看看看详细的介绍: 示例代码: // 创建 stream conte...

PHP实现的mongoDB数据库操作类完整实例

本文实例讲述了PHP实现的mongoDB数据库操作类。分享给大家供大家参考,具体如下: 最近的项目开发中使用的数据库是mongodb数据库,因为小编的公司也是刚刚使用mongodb数据库...

探讨php define()函数及defined()函数使用详解

The define() function defines a constant.define()函数的作用是:定义一个常量。 Constants are much like varia...

discuz图片顺序混乱解决方案

discuz图片顺序混乱解决方案

说明 discuz在发表帖子的时候,添加多张图片,然后直接发表帖子,图片顺序有时候会乱掉 即使上传图片窗口中图片顺序正确,发布之后还是会乱掉 分析 看url,程序代码中看不出什么 将图片...

PHP实现二维数组按指定的键名排序的方法示例

本文实例讲述了PHP实现二维数组按指定的键名排序的方法。分享给大家供大家参考,具体如下: <?php /*二维数组按指定的键值排序*/ function array_s...