Rounding off to the nearest quarter inch.

Discussion in 'AutoCAD' started by Sage Cowsert, Jul 25, 2003.

  1. Sage Cowsert

    Sage Cowsert Guest

    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 Cowsert, Jul 25, 2003
    #1
  2. Sage Cowsert

    Doug Broad Guest

    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
     
    Doug Broad, Jul 25, 2003
    #2
  3. Sage Cowsert

    Sage Cowsert Guest

    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
     
    Sage Cowsert, Jul 25, 2003
    #3
  4. Sage Cowsert

    Joe Burke Guest

    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

     
    Joe Burke, Jul 26, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.