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.

不翻译了。呵呵

相关文章

Yii 2.0如何使用页面缓存方法示例

前言 本文主要给大家介绍的是关于Yii2.0如何使用页面缓存的相关内容,分享出来供大家参考学习,下面来一起看看详细的介绍。 起初使用页面缓存,发现使用于含有参数的方法存在弊端,只能缓存第...

IIS6.0中配置php服务全过程解析

虽然 LAMP 组合很不错,但是如果想要架设一台同时支持 PHP、ASP、ASP.NET、JSP、Perl 的 Web 虚拟主机服务器,还是用 Windows 2003 的 IIS 6...

php中header设置常见文件类型的content-type

在PHP中可以通过header函数来发送头信息,还可以设置文件的content-type,下面整理了一些常见文件类型对于的content-type值。 //date 2015-06-...

PHP的异常处理类Exception的使用及说明

1、首先php5提供了基本的异常处理类,可直接使用 复制代码 代码如下: <?php class Exception { protected $message = 'Unknown...

php中Socket创建与监听实现方法

本文实例讲述了php中Socket创建与监听实现方法。分享给大家供大家参考。具体如下: 这里提供了在php中socket相关函数的一个实例,如创建Socket,接受一个socket连接...