PHP开发实例大全(提高卷) 中文完整pdf扫描版[244MB]
/** * 判断第一个浮点数是否大于第二个浮点数 * @param unknown_type $big * @param unknown_type $small * @param unknown_type $precision * @return boolean */ function floatgtr($big,$small,$precision = 10) {// is one float bigger than another $e = pow(10,$precision); $ibig = intval($big * $e); $ismall = intval($small * $e); if ( $ibig > $ismall ){ return true; }else{ return false; } } /** * 判断两个浮点数是否相等 * @param unknown_type $f1 * @param unknown_type $f2 * @param unknown_type $precision */ function floatcmp($f1,$f2,$precision = 10) {// are 2 floats equal $e = pow(10,$precision); $i1 = intval($f1 * $e); $i2 = intval($f2 * $e); if ( $i1 == $i2 ){ return true; }else{ return false; } } /** * 判断两个浮点数第一个浮点数是否小于第二个浮点数 * @param unknown_type $big * @param unknown_type $small * @param unknown_type $precision * @return boolean */ function floatltr($big,$small,$precision = 10) {// is on float bigger or equal to another $e = pow(10,$precision); $ibig = intval($big * $e); $ismall = intval($small * $e); if ( $ibig < $ismall ){ return true; }else{ return false; } }
转载请注明:谷谷点程序 » php计算两个浮点数大小