Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi need some help, I'm sure it's an easy one. I have this function to convert from DD to DMS but I want it to round to 5 seconds. Would love a hand with this.
Thanks
(defun degtodms (a)
(setq crvdeg (fix a))
;(princ crvdeg)
(setq remain (- a crvdeg))
(setq remain (* remain 60))
(setq crvmin (fix remain))
(setq remain (- remain crvmin))
(setq remain (* remain 60))
;(princ crvmin)
(setq crvsec (fix remain))
(setq remain (- remain crvsec))
(setq remain (* remain 10))
(setq res (fix remain))
;(princ crvsec)
;(princ res)
(if (>= res 5) (setq crvsec (+ crvsec 1)))
(if (= crvsec 60) (progn
(setq crvsec 0) (setq crvmin (+ crvmin 1)))
)
(if (= crvmin 60) (progn
(setq crvmin 0) (setq crvdeg (+ crvdeg 1)))
)
(setq crvdeg (rtos crvdeg 2 0))
(setq crvmin (rtos crvmin 2 0))
(if (= (strlen crvmin) 1)
(setq crvmin (strcat "0" crvmin))
)
(setq crvsec (rtos crvsec 2 0))
(if (= (strlen crvsec) 1)
(setq crvsec (strcat "0" crvsec))
)
(setq a (strcat crvdeg "." crvmin crvsec))
)
Solved! Go to Solution.