PHP中的float类型使用说明

yipeiwu_com4年前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将session信息存储到数据库的类实例

本文实例讲述了PHP将session信息存储到数据库的类。分享给大家供大家参考。具体分析如下: SessionHandlerInterface接口是PHP内置的接口,直接实现就行了 具体...

PHP调用Webservice实例代码

它是一个开源软件,是完全采用PHP语言编写的、通过HTTP收发SOAP消息的一系列PHP类,由NuSphere Corporation(http://dietrich.ganx4.com...

JS中encodeURIComponent函数用php解码的代码

JS中encodeURIComponent函数给中文编码后,如何用php解码?? 前提:编码前的中文可能是gbk,gb2312,utf-8等。 复制代码 代码如下: urldecode(...

PHP中的cookie不用刷新就生效的方法

不过,这种机制总是会给我们带来这或那的问题,比如前段时间,我的站点上得设置一个广告显示的功能,就需要用到COOKIE,主要目的是为了加大广告的转化率,可是如果刷新生效,就比较麻烦,所以就...

PHP 常用数组内部函数(Array Functions)介绍

本章讲述几个常用的 PHP 数组内部函数。 在前面我们已经介绍过PHP 数组,创建一个数组用 array() 函数,删除一个数组元素用 unset() 函数。本章节我们还要学习一些其它常...