Atof Help

Discussion in 'AutoCAD' started by Rad_Cadder, Sep 10, 2004.

  1. Rad_Cadder

    Rad_Cadder Guest

    I'm having trouble with atof!!!
    I need a real number to pass to the polar command and when I take the string and pass it to atof the decimal comes back .0 instead of .36.
    example:
    (setq num "235203.36")
    (atof num) ;returns 235203.0

    Does anyone know of a way to convert string to real without losing original value of string???
     
    Rad_Cadder, Sep 10, 2004
    #1
  2. Rad_Cadder

    Jeff Mishler Guest

    The value is there, you just can't see it.... :)

    _$ (setq num "235203.36")
    "235203.36"
    _$ (setq rnum (atof num))
    235203.0
    _$ (rtos rnum 2 8)
    "235203.36000000"
    _$
     
    Jeff Mishler, Sep 10, 2004
    #2
  3. Rad_Cadder

    Rad_Cadder Guest

    Jeff,
    I realize that the value may be there, but to pass it to a polar command it needs to be passed as the actual value.
     
    Rad_Cadder, Sep 10, 2004
    #3
  4. Rad_Cadder

    Jeff Mishler Guest

    What makes you think that it's not using the actual value? Here's a simple
    test:

    (setq pt1 '(0.0 0.0 0.0))
    (setq add (atof "235203.36"))
    (setq pt2 (polar pt1 (atan 1) add))
    (entmake (list '(0 . "LINE")
    (cons 10 pt1)
    (cons 11 pt2)
    )
    )

    Running this in the vlide returns:
    _$

    (0.0 0.0 0.0)
    235203.0
    (166314.0 166314.0 0.0)
    ((0 . "LINE") (10 0.0 0.0 0.0) (11 166314.0 166314.0 0.0))
    _$

    And listing the new line in the drawing editor:
    Command: _list
    Select objects: 1 found

    Select objects:

    LINE Layer: "STA-GP"
    Space: Model space
    Color: BYLAYER Linetype: "PL"
    Handle = 323
    from point, X= 0.000000 Y= 0.000000 Z= 0.000000
    to point, X=166313.890814 Y=166313.890814 Z= 0.000000
    Length =235203.360000, Angle in XY Plane = 45d0'0"
    Delta X =166313.890814, Delta Y = 166313.890814, Delta Z =
    0.000000

    The line length is the value of the original string........
     
    Jeff Mishler, Sep 10, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.