Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding to the Nearest 0.25 1

Status
Not open for further replies.
Nov 17, 2003
15
GB
Is there an easy way using formatting or local variables, to round a calculation down to the nearest 0.25.

For example if the result of a calculation is 15.16, I want it to display 15.00; 17.34 I want to display 17.25.

I can achieve it using a long winded 'if then' statement looking at the chopped off decimal part of the number and deciding whether it should be x.00 or x.25 or x.50 or x.75 but, this seems really cumbersome. Is there a smarter way to do this?
 
trunc(value*4)/4 may do what you want

I tried to remain child-like, all I acheived was childish.
 
on second thought round(value*4)/4

I tried to remain child-like, all I acheived was childish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top