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正则提取或替换img标记属性

核心代码 <?php /*PHP正则提取图片img标记中的任意属性*/ $str = '<center><img src="/uploads/imag...

利用PHP制作简单的内容采集器的原理分析

前几天做了个小说连载的程序,因为怕更新麻烦,顺带就写了个采集器,采集八路中文网的,功能比较简单,不能自定义规则,不过大概思路都在里面了,自定义规则可以自己来扩展。   用php来做采集器...

php使用escapeshellarg时中文被过滤的解决方法

本文分析了php使用escapeshellarg时中文被过滤的解决方法。分享给大家供大家参考。具体如下: 一、问题: 同样的代码,发现通过 localhost/index.php 访问,...

phpMyAdmin 安装及问题总结

1/无法载入mcrypt扩展,请检查PHP配置; 2/配置文件现在需要绝密的短语密码(blowfish_secret); 3/#2003-服务器没有响应。 由于目前phpMyAdmin的...

分享PHP守护进程类

用PHP实现的Daemon类。可以在服务器上实现队列或者脱离 crontab 的计划任务。  使用的时候,继承于这个类,并重写 _doTask 方法,通过 main 初始化执...