ceiling to the nearest nickel

Dear Friends,

How to round a number in foxpro like the ceiling function in Excel does, giving the number to be rounded as parameter 1 and the multiple we need as parameter 2

eg ; ceiling(4.20,0.05) = 4.50

Is there a possiblity to do the same in foxpro, because the ceiling in foxpro rounds up to the nearest integer

eg: ceiling(4.20) = 5.00

there is noway of specifying the multiple we need as in the case of Excel

Any help would be greatly appreciated.

Thanks

satish



Answer this question

ceiling to the nearest nickel

  • spelger

    sorry i understood the question wrong.

  • Puybaret jean-claude

    Dear Andy,

    Thanks for your quick reply, please note that there was a type error it is not 0.05 but 0.50.

    Thanks for your solution I am trying it .

    bye

    satish


  • Matt237

    Thanks Lakshminarayana,

    It happens sometimes, I am working on it , get u latter

    thanks again

    satish


  • Nick Hertl

    there is a function called ceiling in foxpro. syntax : ceiling(<expn>). where expn is the numeric expression. it just returns the next highest value.

    for eg.

    ceil(10.1) returns 11 and ceil(10.6) also returns 11. ceil(10) returns 10.

    cel(-10.9) returns -10 and ceil(-10.1) returns -10 and ceil(-10) returns -10



  • ParthP

    Check the ROUND() function

    It will round values to the specified number of decimal places.

    (i.e. ROUND( 4.24, 1 ) = 4.2, while ROUND( 4.25, 1) = 4.3 

    To handle special requirements, (how does 4.20 rounded to the nearest 0.05 come out to be 4.5 ) you would have to write your own function to return whatever it is that you need.

    Check out the MOD() function as well. You should be able to use the two to get what you want



  • ceiling to the nearest nickel