PHP中的float类型使用说明

yipeiwu_com5年前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 输出缓冲控制(Output Control)详解

  php 缓冲简介       其实我对php ob 系列印象还是很模糊,具体怎么玩的,还不是很了解,平时curd,确实对...

php socket通信(tcp/udp)实例分析

本文实例讲述了php socket通信(tcp/udp)方法。分享给大家供大家参考,具体如下: 注意 1.在socket_bind的时候ip地址不能真回环地址如127.0.0.1 2.s...

linux下的php-fpm参数配置介绍与参数优化说明

php-fpm.conf重要参数详解 pid = run/php-fpm.pid #pid设置,默认在安装目录中的var/run/php-fpm.pid,建议开启 error_log =...

PHP cdata 处理(详细介绍)

当时在网上找了一个CDATA的转换器, 修改之后, 将CDATA标签给过滤掉。如下复制代码 代码如下: // States:    &n...

php str_pad 函数用法简介

语法 str_pad(string,length,pad_string,pad_type) 参数 描述 string 必需。规定要填充的字符串。 length 必需。规定新字符串的长度。...