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实现快速对二维数组某一列进行组装的方法小结

本文实例总结了php实现快速对二维数组某一列进行组装的方法。分享给大家供大家参考,具体如下: 问题: 比如我二维数组是这样的: $user = array( '0'=> ar...

PHP封装的Twitter访问类实例

本文实例讲述了PHP封装的Twitter访问类。分享给大家供大家参考。具体如下: class Twitter { /** * Method to make twitter ap...

php配置php-fpm启动参数及配置详解

约定几个目录 /usr/local/php/sbin/php-fpm/usr/local/php/etc/php-fpm.conf/usr/local/php/etc/php.ini一,...

rrmdir php中递归删除目录及目录下的文件

复制代码 代码如下: function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($ob...

关于PHP中Object对象的笔记分享

1.当将所有实例设为null,php会自动清除对象的引用。 2.建构子:__construct() 清除对象时自动执行的方法:__destruct() 也可以设置手动清除对象的方法:de...