Anyone has ever programmed a PHP (or perl) function to get the ceiling value Excel style?
TIA
Roberto
Anyone has ever programmed a PHP (or perl) function to get the ceiling value Excel style?
TIA
Roberto
Sorry, not quite clear what 'Excel style' is, but PHP has a ceil function.
"Microsoft Excel's ceiling function does not follow the mathematical definition, but rather as with (int) operator in C, it is a mixture of the floor and ceiling function: for x ≥ 0 it returns ceiling(x), and for x < 0 it returns floor(x). This has followed through to the Office Open XML file format. For example, CEILING(-4.5) returns -5. A mathematical ceiling function can be emulated in Excel by using the formula "-INT(-value)" (please note that this is not a general rule, as it depends on Excel's INT function, which behaves differently that most programming languages)." - from wikipedia
If php's built in ceil function isn't working right you could make a new function like
function excel_ceil($num){
return ($num>0)?ceil($num):floor($num);
}
Hope that helps
Wouldn't you use round
for this instead of calling ceil
if it's too high, or floor
if it's too low?