微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP中的float类型使用说明

float类型的表示可以有以下几种:
<div class="codetitle"><a style="CURSOR: pointer" data="55276" class="copybut" id="copybut55276" onclick="doCopy('code55276')"> 代码如下:

<div class="codebody" id="code55276">
<?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. 不翻译了。呵呵

原文地址:https://www.jb51.cc/php/28413.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐