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获取windows登录用户名的方法

前几天在问答区提了一下这个问题,所有回答问题的朋友都说不可能通过PHP实现,碰巧我的实习负责人帮我找到了一个方法,貌似是通过NTLM来实现的,我是新手,对具体原理也知之不详,只是自己测试...

thinkphp实现把数据库中的列的值存到下拉框中的方法

1. 先去数据库中查值,查询整个数据表,结果为二维数组。 $project = M("project"); $cell = $project->where(array('s...

PHP获取链表中倒数第K个节点的方法

本文实例讲述了PHP获取链表中倒数第K个节点的方法。分享给大家供大家参考,具体如下: 问题 输入一个链表,输出该链表中倒数第k个结点。 解决思路 注意这个题目是返回节点,而不是返回值。返...

php对图像的各种处理函数代码小结

一、创建图片资源 imagecreatetruecolor(width,height);imagecreatefromgif(图片名称);imagecreatefrompng(图片名称)...

php中3种方法统计字符串中每种字符的个数并排序

复制代码 代码如下: <?php //这个方法纯粹是背函数,不解释; function countStr($str){ $str_array=str_split($str); $s...