Changeset 9857 for temp/trunk
- Timestamp:
- 2006/11/30 15:38:54 (20 years ago)
- Location:
- temp/trunk
- Files:
-
- 2 edited
-
data/lib/slib.php (modified) (3 diffs)
-
html/test/kakinaka/tax.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
temp/trunk/data/lib/slib.php
r9856 r9857 1111 1111 function sfRound($value, $pow = 0){ 1112 1112 $adjust = pow(10 ,$pow); 1113 1113 1114 1114 // À°¿ô³î¤Ä0½Ð¤Ê¤±¤ì¤Ð·å¿ô»ØÄê¤ò¹Ô¤¦ 1115 1115 if(sfIsInt($adjust) and $pow > 0){ … … 1127 1127 // ·å¿ô¤ò»ØÄꤷ¤ÆÀÚ¤ê¼Î¤Æ 1128 1128 function sfFloor($value, $digit = 1){ 1129 1130 $digit = $digit-1; 1129 $adjust = pow(10 ,$pow); 1131 1130 1132 1131 // À°¿ô³î¤Ä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 1136 1141 return $ret; 1137 1142 } … … 1139 1144 // ·å¿ô¤ò»ØÄꤷ¤ÆÀÚ¤ê¾å¤² 1140 1145 function sfCeil($value, $digit = 1){ 1141 1142 $digit = $digit-1; 1143 1146 $adjust = pow(10 ,$pow); 1147 1144 1148 // À°¿ô³î¤Ä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 1148 1158 return $ret / 10 * $digit; 1149 1159 } -
temp/trunk/html/test/kakinaka/tax.php
r9849 r9857 4 4 5 5 6 $tax = sfRound(5.4445,3); 6 echo "»Í¼Î¸ÞÆþ¡§" . sfRound(5.4445,3); 7 echo "ÀÚ¤ê¼Î¤Æ¡§" . sfFloor(5.4445,3); 8 echo "ÀÚ¤ê¾å¤²¡§" . sfCeil(5.4445,3); 7 9 8 sfprintr($tax);9 10 10 11 ?>
Note: See TracChangeset
for help on using the changeset viewer.
