ceiling to the nearest nickel  
Author Message
Satish33





PostPosted: Visual FoxPro General, ceiling to the nearest nickel Top

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



Visual FoxPro2  
 
 
AndyKr





PostPosted: Visual FoxPro General, ceiling to the nearest nickel Top

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



 
 
Lakshminarayana





PostPosted: Visual FoxPro General, ceiling to the nearest nickel Top

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



 
 
Lakshminarayana





PostPosted: Visual FoxPro General, ceiling to the nearest nickel Top

sorry i understood the question wrong.

 
 
Satish33





PostPosted: Visual FoxPro General, ceiling to the nearest nickel Top

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


 
 
Satish33





PostPosted: Visual FoxPro General, ceiling to the nearest nickel Top

Thanks Lakshminarayana,

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

thanks again

satish