Jump to content

rtos problem


HARRY-PLOTTER

Recommended Posts

Hi guys,

i'm working on a lisp, and i use rtos and then i reverse a string - a number -260, i use rtos to transform this number in a string - "260" , then i reverse this string - result "62" - but i need a result like "062" - how to do this? i saw Lee Mac lisp for consistent rtos - http://www.lee-mac.com/consistentrtos.html - the same result . Any ideea?

Link to comment
Share on other sites

Hi Harry plotter. (nice name btw) ;)

AFAIK, there are no way to return an integer with preceding zeros

 

(atoi "006") will return 6

 

But, as a string you could. Could you use the returned value as a string directly?

(defun test (input / )
   (while (not (>= (strlen input) 3))
          (setq input (strcat "0" input))
   )
   (princ input)
   (princ))

Command: (test "6")

006

Link to comment
Share on other sites

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...