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.

不翻译了。呵呵

相关文章

在WordPress中实现发送http请求的相关函数解析

在 PHP 中发送 Http 请求(GET / POST)有很多的方法,比如 file_get_contents() 函数、fopen() 函数或者 cURL 扩展,但由于服务器的情况不...

使用php检测用户当前使用的浏览器是否为IE浏览器

复制代码 代码如下: /** * 检测用户当前浏览器 * @return boolean 是否ie浏览器 */ function chk_ie_browser() { $userbrow...

分享3个php获取日历的函数

提供一个日期,获取这个日期的星期对应日历列表,键为星期标示 $month_date = '2015-09-25'; $start_time = strtotime($month_da...

使用ltrace工具跟踪PHP库函数调用的方法

本文实例讲述了使用ltrace工具跟踪PHP库函数调用的方法。分享给大家供大家参考,具体如下: 可能大家已经很熟悉使用strace来跟踪系统调用,今天介绍一个跟踪库函数的利器ltrace...

有关PHP性能优化的介绍

PHP优化对于PHP的优化主要是对php.ini中的相关主要参数进行合理调整和设置,以下我们就来看看php.ini中的一些对性能影响较大的参数应该如何设置。 # vi /etc/php....