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中static关键字原理的学习研究分析

看PHP手册的时候发现了下面这样一段代码: 复制代码 代码如下: <?php function Test() { static $count = 0; $count++; echo...

PHP实现将科学计数法转换为原始数字字符串的方法

本文实例讲述了PHP实现将科学计数法转换为原始数字字符串的方法,分享给大家供大家参考。 具体实现代码如下: 复制代码 代码如下:function NumToStr($num){ &nb...

PHP面向对象程序设计之类常量用法实例

类常量是PHP面向对象程序设计中非常重要的一个概念,牢固掌握类常量有助于进一步提高PHP面向对象程序设计的水平。本文即以实例形式描述了PHP程序设计中类常量的用法。具体如下: 类常量:类...

php和js交互一例-PHP教程,PHP应用

复制代码 代码如下:<html>  <head>  <meta http-equiv="Content-Type" ...

php算开始时间到过期时间的相隔的天数

复制代码 代码如下://mktime = mktime($hours,minute,seconds,month,day,years) $start_time = mktime(0,0,0...