HARRY-PLOTTER Posted November 7, 2014 Posted November 7, 2014 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? Quote
7o7 Posted November 7, 2014 Posted November 7, 2014 You can use this. (vl-list->string (reverse (vl-string->list "260"))) Quote
meracl Posted November 7, 2014 Posted November 7, 2014 If your number is an integer 260 and not 260.00 use itoa instead of rtos. Quote
Jef! Posted November 7, 2014 Posted November 7, 2014 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 Quote
Recommended Posts
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.