Author Topic: rounding problem  (Read 1066 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
rounding problem
« on: May 13, 2013, 12:55:19 PM »
Anyone know why this is rounding 33.09 to .2 rather than .1?

Thanks!
Code: [Select]
(defun c:hp (/ padinc en elev padff test padorig newpad newpad2 new FF)
(defun round+ (num prec)
  (if (< 0 prec)
    (* prec
       (if (minusp (setq num (/ num prec)))
     (fix num)
     (if (= num (fix num))
       num
       (fix (1+ num))
     )
       )
    )
    num
  )
)
(initerr)
(setq ff 0.7);finish floor to pad grade difference
(setq x 1)
(setq padinc (getreal "\nHow far above Tc Elev?"))
       (while (= x 1)
  (command "undo" "BE") ;undo BEGIN
(prompt "\nSelect TC Elevation...")
(setq en (entsel))
  (setq elev (entget (car en )))
  (setq elev (cdr (assoc 1 elev)))
          (setq elev (substr elev 1))
  (setq elev (atof elev))
          (setq elev (round+ elev 0.1))
(setq padff (entsel "\nSelect HP Block"))
(setq test (entget (car padff)))
(setq padorig (entget (entnext (dxf -1 test))))
(setq oldpad (assoc 1 padorig))
(setq newpad (+ elev padinc))
(setq newpad2 (rtos newpad 2 1))
(setq newpad2 (substr newpad2 3))
(setq new (cons 1 newpad2))
(entmod (subst new oldpad padorig))
(entupd (cdr (car padorig)))
(command "undo" "M") ;undo MARK
(command "undo" "E") ;undo END
       );while
(princ)
(RESET)
);defun

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: rounding problem
« Reply #1 on: May 13, 2013, 10:07:26 PM »
Nevermind... it appears to be working appropriately. It was OE I think.