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正则表达式中的非贪婪模式匹配的使用

通常我们会这么写: 复制代码 代码如下: $str = "http://www.baidu/.com?url=www.sina.com/"; preg_match("/http:(.*)...

PHP后期静态绑定实例浅析

本文实例讲述了PHP后期静态绑定。分享给大家供大家参考,具体如下: 从php5.3开始,php增加了一个叫后期绑定的功能,用于在继承范围内引用静态调用的类 该功能从语言内部角度考虑北命名...

sourcesafe管理phpproj文件的补充说明(downmoon)

sourcesafe管理phpproj文件的补充说明(downmoon)

后来发现sourcesafe管理界面,(Admin登录),tools——Options——File Types——File Group——Add "PHP"——“*.php;*.phpp...

PHP中的str_repeat函数在JavaScript中的实现

PHP中有一个函数:String str_repeat($str, num);挺好用的....以下通过js和php模拟实现。 1:PHP版本 复制代码 代码如下: /*PHP版实现*/...

PHP学习笔记之三 数据库基本操作

下面是在Linux上登录mysql,创建数据库和创建表的过程。 yin@yin-Ubuntu10:~$ mysql -u root -p Enter password: Welcome...