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.

不翻译了。呵呵

相关文章

解决GD中文乱码问题

今天仔细研究了下GD的一些相关技术,顺手也研究下GD中文乱码的问题。  使用GD库输出中文字符串,调用imagestring是没有用的。需要使用imagettftext()函数...

thinkphp修改配置进入默认首页的方法

thinkphp文件夹下config 里面有个convention.php文件 里面有三个配置 'DEFAULT_MODULE' => 'Home', // 默认模块 'DEF...

php中常用字符串处理代码片段整理

移除 HTML 标签 复制代码 代码如下: $text = strip_tags($input, ""); 上面的函数主要是使用了strip_tags,具体的使用说明参考。   返回...

PHP面向对象程序设计模拟一般面向对象语言中的方法重载(overload)示例

本文实例讲述了PHP模拟一般面向对象语言中的方法重载(overload)。分享给大家供大家参考,具体如下: 在一般的面向对象设计语言(如C++,Java)中的方法重载就是定义相同的方法名...

php中strtotime函数用法详解

本文实例讲述了php中strtotime函数用法。分享给大家供大家参考。具体如下: strtotime(字符串$时间[,诠释$现在])int strtotime(string $time...