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中ob_flush函数和flush函数用法分析

本文实例分析了php中ob_flush函数和flush函数用法。分享给大家供大家参考。具体如下: ob_flush()函数: 取出PHP buffering中的数据,放入server b...

在php7中MongoDB实现模糊查询的方法详解

前言 在实际开发中, 有不少的场景需要使用到模糊查询, MongoDB shell 模糊查询很简单: db.collection.find({'_id': /^5101/}) 上...

php调用KyotoTycoon简单实例

本文实例讲述了php调用KyotoTycoon的方法。分享给大家供大家参考。具体如下: Kyoto Tycoon(简称KT)是Tokyo Tyrant 的作者Mikio Hirabaya...

php下统计用户在线时间的一种尝试

下面列出几个比较常用的方法: 首先介绍一下所涉及的数据表结构,四个字段: 复制代码 代码如下: uid<int(10)> :用户id session_id<varcha...

PHP生成随机数的方法总结

第一种方法用mt_rand() function GetRandStr($length){ $str='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL...