Jump to content

what is the rounding of number function in autolisp ???


Recommended Posts

Posted

hi guys

how do you do

in excel we write this function =ceiling (number; 05) for examble

in autolisp what is the same function to do this ??

I.E : if i have a number ( 2.63) ... and i want the cad give it as ( 2.65)

what must i use ??

i assumed i can use (ceiling 2.63 0.05)

but it is bad function

thank you and sorry for my bad english

Posted

Consider the following function:

;; Round Up  -  Lee Mac
;; Rounds 'n' up to the nearest 'm'

(defun LM:roundup ( n m )
   (cond
       ((equal 0.0 (rem n m) 1e- n)
       ((< n 0) (- n (rem n m)))
       ((+ n (- m (rem n m))))
   )
)

 

Example of usage:

_$ (LM:roundup 2.61 0.05)
2.65

Posted

thank you alot

you are awesome people

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...