zamri_uut Posted January 24, 2015 Share Posted January 24, 2015 I am trying to set up a lisp to change the format of various rawdata , the problem is now I can not write such a long number 1000000452536 and it will write as 1.0e + 012 . is there a way to write numbers in the original format ? Thank precedence . Please pardon my language . Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 24, 2015 Share Posted January 24, 2015 maybe try (rtos numb 2 12) Quote Link to comment Share on other sites More sharing options...
zamri_uut Posted January 24, 2015 Author Share Posted January 24, 2015 Sorry Bigal , it will provide " 1.000000000000E + 18 " , I have to write " 1000000004546 " as the original . eg " ( SUBSTR ( RTOS ( + 10000000000000000 PNUM ) 2 0 ) 2 16 ) " I need an answer as " 0000000000256489 " . is there any idea? Please pardon my language . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 24, 2015 Share Posted January 24, 2015 The double-precision floating-point format (usually referred to as simply a 'double', or in AutoLISP, a 'real') is inherently limited to 15 decimal digits of precision. Hence, when working with numbers such as you have provided, you will lose any precision after the 15th decimal digit: [color=red]100000000000000[/color]00 Quote Link to comment Share on other sites More sharing options...
zamri_uut Posted January 24, 2015 Author Share Posted January 24, 2015 Thanks Lee , I really appreciate it . there are other ways that can be done as VB : FORMAT ( PNUM , " 0000000000000000 " ) ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 24, 2015 Share Posted January 24, 2015 If the data remains a string, you could add the two numbers by comparing the strings digit-by-digit, for example, consider the following function: (defun addstrings ( s1 s2 / foo bar str->lst lst->str ) (defun foo ( x l ) (if (< 0 x) (if l (cons (rem (+ x (car l)) 10) (foo (/ (+ x (car l)) 10) (cdr l))) (cons (rem x 10) (foo (/ x 10) l)) ) l ) ) (defun bar ( a b ) (if a (bar (mapcar '(lambda ( x ) (* x 10)) (cdr a)) (foo (car a) b)) (reverse b)) ) (defun str->lst ( s ) (mapcar '(lambda ( x ) (- x 48)) (reverse (vl-string->list s))) ) (defun lst->str ( l ) (vl-list->string (mapcar '(lambda ( x ) (+ x 48)) l)) ) (lst->str (apply 'bar (mapcar 'str->lst (if (< (strlen s1) (strlen s2)) (list s1 s2) (list s2 s1))))) ) Applied to your example: _$ (addstrings "10000000000256489" "825932628") "10000000826189117" Quote Link to comment Share on other sites More sharing options...
zamri_uut Posted January 24, 2015 Author Share Posted January 24, 2015 Thanks Lee , it was as I expected, I will try to learn from it.:D:D Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 24, 2015 Share Posted January 24, 2015 You're welcome! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 24, 2015 Share Posted January 24, 2015 Just a dumb question are you designing the trajectory alignment from you home to the moon in mm ? Awful big number. Quote Link to comment Share on other sites More sharing options...
zamri_uut Posted January 25, 2015 Author Share Posted January 25, 2015 Sorry , I tried to convert the machine code as the code below : *110040+0000000000000012 84..10-0000000000065045 85..10-0000000000058120 86..10+0000000000015502 87..10+0000000000001350 88..10+0000000000001485 79....+0000000000000010 *110041+0000000000000013 21.324+0000000024647210 22.324+0000000008851000 31..00+0000000000093414 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000150881 82..00-0000000000094929 83..00+0000000000017512 71....+0000000000000PKT 72....+000000000000000J *110042+0000000000000137 21.324+0000000025004140 22.324+0000000008844170 31..00+0000000000079145 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000139432 82..00-0000000000085091 83..00+0000000000017381 71....+000000000000000J 72....+000000000000000J *110043+0000000000000138 21.324+0000000024635510 22.324+0000000008855460 31..00+0000000000076505 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000135244 82..00-0000000000088502 83..00+0000000000017067 71....+000000000000000J 72....+000000000000000J *110044+0000000000000139 21.324+0000000033927550 22.324+0000000009506470 31..00+0000000000005234 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000066874 82..00-0000000000053238 83..00+0000000000015170 71....+000000000000000J 72....+000000000000000J *110045+0000000000000140 21.324+0000000025001290 22.324+0000000008859240 31..00+0000000000053360 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000115187 82..00-0000000000076346 83..00+0000000000016578 71....+000000000000000J 72....+000000000000000J *110046+0000000000000141 21.324+0000000025613070 22.324+0000000008834480 31..00+0000000000052312 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000115836 82..00-0000000000070578 83..00+0000000000016933 71....+000000000000000J 72....+000000000000000J *110047+0000000000000142 21.324+0000000026251570 22.324+0000000008844380 31..00+0000000000030960 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000095758 82..00-0000000000061964 83..00+0000000000016316 71....+000000000000000J 72....+000000000000000J *110048+0000000000000143 21.324+0000000025236020 22.324+0000000008901390 31..00+0000000000029009 51..1.+000000000000+034 87..10+0000000000001350 81..00-0000000000092723 82..00-0000000000066793 83..00+0000000000016129 71....+000000000000000J 72....+000000000000000J Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 25, 2015 Share Posted January 25, 2015 My version now you can do something *110040+12 84..10-000065045 85..10-000058120 86..10+000015502 87..10+000001350 88..10+000001485 79....+10 *110041+13 21.324+024647210 22.324+008851000 31..00+000093414 51..1.+00000+034 87..10+000001350 81..00-000150881 82..00-000094929 83..00+000017512 71....+000000PKT 72....+0J *110042+000000137 21.324+025004140 22.324+008844170 31..00+000079145 51..1.+00000+034 87..10+000001350 81..00-000139432 82..00-000085091 83..00+000017381 71....+0J 72....+0J Quote Link to comment Share on other sites More sharing options...
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.