侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

PHP中的float类型使用说明

2023-12-03 星期日 / 0 评论 / 0 点赞 / 22 阅读 / 998 字

float类型的表示可以有以下几种: 复制代码 代码如下: <?php $a = 1.234; $b = 1.2e3; $c = 7E-10; ?> 使用PHP的float类型需要注意的是:PHP的float类型的精度

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.

不翻译了。呵呵

广告 广告

评论区