PHP中的float類型使用說明
更新時間:2010年07月27日 19:41:04 作者:
使用PHP的float類型需要注意的是:PHP的float類型的精度有點問題。如果需要高精度的數學計算,可以使用php提供的專用的數學函數 arbitrary precision math functions系列和gmp系列函數。
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
$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函數ip2long轉換IP時數值太大產生負數的解決方法
本篇文章是對PHP函數ip2long轉換IP時數值太大產生負數的解決方法進行了詳細的分析介紹,需要的朋友參考下2013-06-06
php實現(xiàn)的Timer頁面運行時間監(jiān)測類
這篇文章主要介紹了php實現(xiàn)的Timer頁面運行時間監(jiān)測類,可實現(xiàn)按不同key檢測不同的運行時間,需要的朋友可以參考下2014-09-09
PHP中file_exists()判斷中文文件名無效的解決方法
這篇文章主要介紹了PHP中file_exists()判斷中文文件名無效的解決方法,是很多PHP開發(fā)人員都會遇到的問題,主要涉及對編碼的轉換,需要的朋友可以參考下2014-11-11

