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中for循环与foreach的区别

for循环与foreach的区别 foreach 依赖 IEnumerable. 第一次 var a in GetList() 时调用 GetEnumerator 返回第一个对象并赋给a...

追求程序速度,而不是编程的速度

        1.使用内嵌的HTML代码,而不是PHP的echo语句。 因为PHP是一门嵌入式Web编程...

php简单判断文本编码的方法

本文实例讲述了php简单判断文本编码的方法。分享给大家供大家参考。具体如下: 这里通过对文本的一次循环编码,来判断是否属于该编码。 public function chkCode($...

php UTF8 文件的签名问题

也就是 有BOM 格式编码,或者 无BOM格式编码。 如果看文件的内容,是看不出任何差别的,以下列文件(schema.sqlite.sql)内容为例: schema.sqlite.sql...

静态html文件执行php语句的方法(推荐)

HTM文件中的PHP语句不会被执行,如何在HTML文件中运行php代码? html文件执行php语句的方法: 1,修改httpd.conf,命令Apache把HTML当作PHP, 需要修...