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.

不翻译了。呵呵

相关文章

Thinkphp中import的几个用法详细介绍

下面附上import的几个用法介绍 1、用法一 import('@.Test.Translate'); @,表示项目根目录。假定根目录是:App/ 导入类库的路径是:App/Lib/Te...

PHP中Socket连接及读写数据超时问题分析

本文实例讲述了PHP中Socket连接及读写数据超时问题。分享给大家供大家参考,具体如下: 虽然PHP中对fsockopen()方法有连接socket的超时参数,但是没有类似C中的连接成...

php设计模式 Prototype (原型模式)代码

复制代码 代码如下:<?php /** * 原型模式 * * 用原型实例指定创建对象的种类.并且通过拷贝这个原型来创建新的对象 * */ abstract class Protot...

PHP 字符串 小常识

注意转义字符\的使用\\,\",\$ 注意使用8进制或16进制字符表示 \xf6 echo "H\xf6me";//需要察看是否支持此类文字编码 --------------------...

Discuz! 5.0.0论坛程序中加入一段js代码,让会员点击下载附件前自动弹出提示窗口

你需要修改attachment.php文件 在根目录下  在$attachexists = $ispaid = FALSE;下...