復(fù)制代碼 代碼如下:
<?php
$a = 1.234;
$b = 1.2e3;
$c = 7E-10;
?>
使用php的float類型需要注意的是:php的float類型的精度有點(diǎn)問題。如果需要高精度的數(shù)學(xué)計(jì)算,可以使用php提供的專用的數(shù)學(xué)函數(shù) arbitrary precision math functions系列和gmp系列函數(shù)。還有就是不要試圖進(jìn)行比較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技術(shù):PHP中的float類型使用說(shuō)明,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。