+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Senior Member alijahed's Avatar
    Computer Details
    alijahed's Computer Details
    Operating System:
    Windows 7
    Computer:
    DELL M4500
    Using
    Inventor 2014
    Join Date
    Apr 2007
    Location
    Melbourne
    Posts
    486

    Default Rounded figures!

    Hi All,

    I wrote a lisp and I get rounded results instead of actual real results. Because it is a long lisp I took out the part that create the rounded figure for me.
    firstly, I wrote an external function for ArcSin and I call it here as asin:
    (defun asin (x)
    (ATAN X (SQRT (- 1 (* X X))))
    )
    (defun c:test ()
    (setq rad 4259.0623)
    ;Angle variables
    (setq angButt (* 2 (asin (/ (/ 8 2) rad))))
    (setq angSinkless (* 2 (asin (/ (/ 4 2) rad))))

    (print angButt)
    (print angSinkless)

    ;Arc length variables
    (setq arcButt (* angButt rad))
    (setq arcSinkless (* angSinkless rad))

    (print arcButt)
    (print arcSinkless)

    (princ)
    )
    The result are:

    Command: test
    0.00187835
    0.000939174
    8.0
    4.0
    Command:
    As you see I receive 8.0 and 4.0 the rounded figures.
    How can I fix this?

  2. #2
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Motherboard:
    Intel DZ77RE-75K
    CPU:
    i7-3770K 3.50GHz
    RAM:
    32GB
    Graphics:
    Nvidia Quadro 2000
    Primary Storage:
    125GB SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    ASUS 27" / ASUS 24"
    Discipline
    Civil
    Using
    Civil 3D 2014
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    3,880

    Default

    Code:
    (rtos arcButt 2 16)

  3. #3
    Senior Member alijahed's Avatar
    Computer Details
    alijahed's Computer Details
    Operating System:
    Windows 7
    Computer:
    DELL M4500
    Using
    Inventor 2014
    Join Date
    Apr 2007
    Location
    Melbourne
    Posts
    486

    Default

    Thanks for your reply,
    I found the the rest of it on Help.

    Cheers

  4. #4
    Luminous Being
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    5,001

    Default

    Also lisp does some funy things somtimes if you use integers v's reals in your code / x 2 may give a different answer to / x 2.0

  5. #5
    Senior Member alijahed's Avatar
    Computer Details
    alijahed's Computer Details
    Operating System:
    Windows 7
    Computer:
    DELL M4500
    Using
    Inventor 2014
    Join Date
    Apr 2007
    Location
    Melbourne
    Posts
    486

    Default

    problem!!!

    by using "rtos" I will receive the real number as "string" so I cannot do other calculations using that number. I know "atof" to convert that to real number but it is not the best way.
    Is there any way to force LISP to calculate with the highest precision which I think it is 16 digits?

  6. #6
    Senior Member alijahed's Avatar
    Computer Details
    alijahed's Computer Details
    Operating System:
    Windows 7
    Computer:
    DELL M4500
    Using
    Inventor 2014
    Join Date
    Apr 2007
    Location
    Melbourne
    Posts
    486

    Default

    I think Autolisp does the calculations up to 16 digits but when you ask it to print it rounds the figure.

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,915

    Default

    Registered forum members do not see this ad.

    The calculation is always done with maximum precision. When print as string, if you don't specify the number of decimals, the RTOS function will apply the value set by LUNITS system variable. This is the explanation of that rounding.
    So, don’t have to be afraid, that affects only the display of string – internally it is retained and used with maximum precision.

    Regards,
    Mircea

Similar Threads

  1. Create points on figures
    By rlshound in forum Civil 3D & LDD
    Replies: 0
    Last Post: 9th Dec 2010, 09:05 pm
  2. Text figures as geometry and tool bar size
    By Quik&Easy in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 27th Nov 2010, 12:04 am
  3. Turning inventor designs to figures for a US patent
    By amerdsp in forum Autodesk Inventor
    Replies: 7
    Last Post: 10th Jul 2010, 04:29 pm
  4. figures in stright line
    By autoCAD_dhruv in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 18th Dec 2006, 11:04 am
  5. Trying to get a circle to be rounded out
    By Raider in forum AutoCAD General
    Replies: 8
    Last Post: 16th Aug 2006, 12:10 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts