欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP中的float类型使用说明

程序员文章站 2022-07-19 18:37:57
float类型的表示可以有以下几种: 复制代码 代码如下: 使用ph...
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.

不翻译了。呵呵