+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Senior Member Small Fish's Avatar
    Using
    AutoCAD 2010
    Join Date
    May 2009
    Location
    Tauranga
    Posts
    282

    Default comparing decimal numbers

    Registered forum members do not see this ad.

    I am not sure why this one plays up - If Rad = Radius - deduced previously from a selected circle. Why can't I set "MyValue" when the radius is at say 7.6?
    Is it because I need a fudge factor or is there something else I am missing?


    (if
    (or
    ( = Rad 6.35)
    ( = Rad 7.6)
    );or

    (setq MyValue (* 2.0 rad))
    );if

    thanks

  2. #2
    Full Member
    Using
    not specified
    Join Date
    Mar 2005
    Posts
    53

    Default

    Hi,

    It worked for me. I'll lay money the problem is your value for Rad is not what you think it is.

    Have a good one.
    Shawndoe

  3. #3
    Senior Member Small Fish's Avatar
    Using
    AutoCAD 2010
    Join Date
    May 2009
    Location
    Tauranga
    Posts
    282

    Default

    Yes but Rad for example when I look at value in the watch window is 7.6 yet it does not want to set "MyValue"
    Perhaps its some other problem?

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,714

    Default

    You could use equal instead of = as with = the two expressions must be identical to return true.

    With equal you can specify a fuzz, say 0.0001 or something similar.

    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  5. #5
    Senior Member
    Using
    Map 3D 2008
    Join Date
    Apr 2009
    Location
    The one after 909
    Posts
    402

    Default

    Probably a silly suggestion, but you might also want to consider your units. Even if a number determined via LISP has several places after the decimal point, viewing that number will be subject to the units of your drawing, and if you don't allow any more than, say, 1 digits after the decimal point to be displayed, any number that is 7.6whatever will display as 7.6.
    ~* And, in the end, the love you take *~
    ~* Is equal to the love you make *~
    - The Beatles -


    GrPlayground
    / Text Find/Replace / Batch Engine / Tower Defense

  6. #6
    Senior Member TimSpangler's Avatar
    Using
    Architecture 2009
    Join Date
    Jan 2008
    Location
    Gettyburg, PA
    Posts
    212

    Default

    Quote Originally Posted by Lee Mac View Post
    You could use equal instead of = as with = the two expressions must be identical to return true.

    With equal you can specify a fuzz, say 0.0001 or something similar.

    I was going to suggest the same thing. I prefer (equal) to (=) in most cases concerning numeric values just for the fuzz
    Timothy Spangler
    --theswamp--

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,714

    Default

    Quote Originally Posted by TimSpangler View Post
    I was going to suggest the same thing. I prefer (equal) to (=) in most cases concerning numeric values just for the fuzz
    Great minds think alike eh Tim...
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  8. #8
    Senior Member TimSpangler's Avatar
    Using
    Architecture 2009
    Join Date
    Jan 2008
    Location
    Gettyburg, PA
    Posts
    212

    Default

    I've heard that.......
    Timothy Spangler
    --theswamp--

  9. #9
    Senior Member Small Fish's Avatar
    Using
    AutoCAD 2010
    Join Date
    May 2009
    Location
    Tauranga
    Posts
    282

    Default

    thanks guys the fuzz factor seemed to do the trick using 'equal'

  10. #10
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925

    Default

    Registered forum members do not see this ad.

    If you need differing fuzz factors you can use something like this:

    Code:
    Command: (setq r 2.6)
    2.6
    
    Command: (<= 2.599 r 2.6000000000001)
    T
    -David
    R12 (Dos) - A2K

Similar Threads

  1. Comparing 3D DWFs
    By rob150588 in forum Autodesk Software General
    Replies: 4
    Last Post: 6th Mar 2009, 04:45 pm
  2. Comparing drawings?
    By RingSteel in forum AutoCAD General
    Replies: 4
    Last Post: 23rd May 2008, 03:27 pm
  3. Determining decimal numbers?
    By muck in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Jan 2007, 11:51 am
  4. calculator numbers to 8 decimal places
    By BEACHCOMBER in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 23rd Jan 2007, 09:38 am
  5. adding numbers to numbers
    By philk in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Feb 2006, 05:45 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