Changeset 9857 for temp/trunk


Ignore:
Timestamp:
2006/11/30 15:38:54 (20 years ago)
Author:
kakinaka
Message:

blank

Location:
temp/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • temp/trunk/data/lib/slib.php

    r9856 r9857  
    11111111function sfRound($value, $pow = 0){ 
    11121112    $adjust = pow(10 ,$pow); 
    1113      
     1113 
    11141114    // À°¿ô³î¤Ä0½Ð¤Ê¤±¤ì¤Ð·å¿ô»ØÄê¤ò¹Ô¤¦ 
    11151115    if(sfIsInt($adjust) and $pow > 0){ 
     
    11271127// ·å¿ô¤ò»ØÄꤷ¤ÆÀÚ¤ê¼Î¤Æ 
    11281128function sfFloor($value, $digit = 1){ 
    1129      
    1130     $digit = $digit-1; 
     1129    $adjust = pow(10 ,$pow); 
    11311130     
    11321131    // À°¿ô³î¤Ä0½Ð¤Ê¤±¤ì¤Ð·å¿ô»ØÄê¤ò¹Ô¤¦ 
    1133     if(sfIsInt($digit) and $digit != 0) $value = $value * 10 * $digit; 
    1134     $ret = floor($value); 
    1135     $ret = floor($ret/$adjust); 
     1132    if(sfIsInt($adjust) and $pow > 0){ 
     1133        $ret = (floor($value * $adjust)/$adjust); 
     1134        $ret = sfFloor($ret, $pow - 1); 
     1135        return $ret; 
     1136    }else{ 
     1137        $ret = floor($value); 
     1138        $ret = floor($ret/$adjust); 
     1139    } 
     1140     
    11361141    return $ret; 
    11371142} 
     
    11391144// ·å¿ô¤ò»ØÄꤷ¤ÆÀÚ¤ê¾å¤² 
    11401145function sfCeil($value, $digit = 1){ 
    1141      
    1142     $digit = $digit-1; 
    1143  
     1146    $adjust = pow(10 ,$pow); 
     1147     
    11441148    // À°¿ô³î¤Ä0½Ð¤Ê¤±¤ì¤Ð·å¿ô»ØÄê¤ò¹Ô¤¦ 
    1145     if(sfIsInt($digit) and $digit != 0) $value = $value * 10 * $digit; 
    1146     $ret = ceil($value); 
    1147     $ret = floor($ret/$adjust); 
     1149    if(sfIsInt($adjust) and $pow > 0){ 
     1150        $ret = (floor($value * $adjust)/$adjust); 
     1151        $ret = sfCeil($ret, $pow - 1); 
     1152        return $ret; 
     1153    }else{ 
     1154        $ret = ceil($value); 
     1155        $ret = floor($ret/$adjust); 
     1156    } 
     1157 
    11481158    return $ret / 10 * $digit; 
    11491159} 
  • temp/trunk/html/test/kakinaka/tax.php

    r9849 r9857  
    44 
    55 
    6 $tax = sfRound(5.4445,3); 
     6echo "»Í¼Î¸ÞÆþ¡§" . sfRound(5.4445,3); 
     7echo "ÀÚ¤ê¼Î¤Æ¡§" . sfFloor(5.4445,3); 
     8echo "ÀÚ¤ê¾å¤²¡§" . sfCeil(5.4445,3); 
    79 
    8 sfprintr($tax); 
    910 
    1011?> 
Note: See TracChangeset for help on using the changeset viewer.