Rounding off to the nearest quarter inch.

  • Thread starter Thread starter Sage Cowsert
  • Start date Start date
S

Sage Cowsert

I'm looking for a way to round off a number to the nearest quarter inch.
Anyone have any leads for me? Say send a sub routine 3/8 and have it spit
out 1/2.

Thanks Sage
 
Sage,
Here is one from a thread 2/19/03. I wrote it with some
help from Joe Burke and Peter Toby. Joe also had one
from that thread.

(defun round (value to)
(setq to (abs to))
(* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to)))
)

Regards,
Doug
 
Wow that's great! Just what I'm after. So simple too, I love it.

--
Remove the 50+1 in my email address to reply
Doug Broad said:
Sage,
Here is one from a thread 2/19/03. I wrote it with some
help from Joe Burke and Peter Toby. Joe also had one
from that thread.

(defun round (value to)
(setq to (abs to))
(* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to)))
)

Regards,
Doug
 
Sage,

Doug's function may appear simple because he's so good at condensing code
down to bare essentials. But it isn't. If you tried to write this function
yourself, you'll know what I mean.

Joe Burke

Sage Cowsert said:
Wow that's great! Just what I'm after. So simple too, I love it.
 
Back
Top