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扩展vld查看PHP opcode操作步骤

首先下载最新版vld扩展: 复制代码 代码如下: ~/public_html/php-5.3.13/ext> wget http://pecl.php.net/get/vld-0....

php 类中的常量、静态属性、非静态属性的区别

一.类常量:在类中始终保持不变的值定义为常量 类的常量不能使用访问限制修饰符,他是 public 的,可继承,可以被子类重写,访问类的常量必须使用双冒号 :: ,可以使用类名或类的实例来...

PHP多维数组排序array详解

PHP数组Array按字段排序 /** * Sort array by filed and type, common utility method. * @param...

PHP面向对象程序设计实例分析

本文实例分析了PHP面向对象程序设计方法。分享给大家供大家参考,具体如下: 在对超大型项目的开发过程中,如果使用面向过程地开发,代码量是非常的庞大,这将大量的用到判断和循环嵌套,和很多很...

php批量转换文件夹下所有文件编码的函数类

函数代码: <?php /** * 把一个文件夹里的文件全部转码 只能转一次 否则全部变乱码 * @param string $filename */ funct...