last digit in a large number

Discussion in 'AutoCAD' started by clay_p, Apr 26, 2004.

  1. clay_p

    clay_p Guest

    Does anyone know of a command that will extract the last digit from a number.

    For example, if i have the number 293320.021384, is there a command that will return the 4 from that number?

    Thanks for any help...
     
    clay_p, Apr 26, 2004
    #1
  2. (setq Str_Real (rtos 293320.021384 2 6))
    (setq Last_Num (substr Str_Real (strlen Str_Real)))

    This assumes you know the number of decimal places in the number, otherwise
    the code will be a lot longer.
    Alan
     
    Alan Henderson, Apr 26, 2004
    #2
  3. clay_p

    clay_p Guest

    thanks, but i decided to convert it to a string and work with it that way.
     
    clay_p, Apr 26, 2004
    #3
  4. Hi clay_p
    try this:

    (setq long-num 293320.021384)
    (setq num-as-string (rtos long-num 2 17))
    (print (substr num-as-string (strlen num-as-string)))

    Regards
    Dieter
     
    Dieter Berger, Apr 26, 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.