Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/29/2020 in all areas

  1. @Stefan BMR , nice job , I'm sure you-know-who probably can come up with a more generic formula but it's the end result that counts.
    1 point
  2. I was about to bring this challenge up So, this is a way to multiply large positive numbers: (defun multip (a b / q m n r c l) (setq q (max (length a) (length b))) (repeat (- q (length a)) (setq a (cons 0 a)) ) (repeat (- q (length b)) (setq b (cons 0 b)) ) (setq c 0) (repeat q (setq q (1- q) m (cons (nth q a) m) n (cons (nth q b) n) r (+ c (apply '+ (mapcar '* m (reverse n)))) c (/ r 10) l (cons (rem r 10) l) ) ) (setq n (reverse n) m (reverse m) ) (while (setq m (cdr m)) (setq n (cdr n) r (+ c (apply '+ (mapcar '* m (reverse n)))) c (/ r 10) l (cons (rem r 10) l) ) ) (while (> c 0) (setq l (cons (rem c 10) l) c (/ c 10) ) ) (while (zerop (car l)) (setq l (cdr l))) l ) _$ (MULTIP '(4 1 2 8 6 6 3 0 7) '(2 4 9 5 1 3 6 1 6)) (1 0 3 0 1 5 7 6 5 1 8 4 1 3 6 1 1 2) _$ (MULTIP '(4 1 2 8 6 6 3 0 7 4 1 2 8 6 6 3 0 7 4 1 2 8 6 6 3 0 7) '(2 4 9 5 1 3 6 1 6 2 4 9 5 1 3 6 1 6 2 4 9 5 1 3 6 1 6)) (1 0 3 0 1 5 7 6 5 3 9 0 1 6 7 6 4 2 6 7 7 3 1 9 5 1 9 7 5 8 4 3 9 8 6 6 4 7 1 2 8 7 9 8 9 1 8 4 1 3 6 1 1 2) _$ More efficient would be to divide the original number in fractions of thousand. The lisp above will work if 10 is replaced by 1000. But I'm more interested of some clever codes. Mine is (almost) just a translation of the way the kids are doing multiplication in class. ... and the test function (defun test (a b / l1 l2) (if (and (eq (type a) 'int) (eq (type b) 'int) ) (progn (while (> a 0) (setq l1 (cons (rem a 10) l1) a (/ a 10) ) ) (while (> b 0) (setq l2 (cons (rem b 10) l2) b (/ b 10) ) ) ;;; (alert (apply 'strcat (mapcar 'itoa (multip l1 l2))) ;;; ) ) ) ) _$ (test 412866307 249513616) "103015765184136112" _$
    1 point
  3. you can increase the precision with units command (or LUPREC) and /or use RTOS like (rtos i 2 8) but AutoCad will only display numbers to a certain max/min value and after that is switches automatically to scientific notation. from help RTOS: The rtos function returns a string that is the representation of number according to the settings of mode, precision, and the AutoCAD UNITMODE, DIMZIN, LUNITS, and LUPREC system variables. The mode and precision arguments correspond to the AutoCAD LUNITS and LUPREC system variables. If you omit the arguments,rtos uses the current settings of LUNITS and LUPREC. so (setq num (rtos (* 412866307.0 249513616.0) 2 16)) would give a few more decimals but unfortunately its still not enough for what you want. Not sure if its possible to first devide both numbers by lets say ten thousand and calculate before and after decimal point separately and join them afterwards. I don't have a degree in math like master Lee.
    1 point
  4. Integers in AutoLISP are stored as 32-bit signed integers, which have an upper limit of (2^31)-1 = 2,147,483,647. Exceeding this limit will cause the sign bit to be flipped, causing the number to wrap around to -2^31 = -2,147,483,648.
    1 point
  5. $ (rtos (* 412866307.0 249513616.0) 2) "1.0302E+17" _$ (rtos (* (float 412866307) (float 249513616)) 2) "1.0302E+17" _$
    1 point
  6. It may be worthwhile posting code as it looks like you have done a good job on the output, there may be some coding improvements that give speed, like the text use entmake much faster than if you have used command text. You can add a progress bar to show that it is working. "acet-ui-progress" look up help.
    1 point
  7. Glad BlackBox's lisp worked for you! The prompts for the DVIEW command changed slightly a few versions back, in my first post an additional macro I believe should work for older versions but I have no way to test it as all I use now is 2021 versions. While coding in lisp as BlackBox did requires a learning curve the code rarely needs updating . Creating macro's is simple as noting how you achieve something using a command. Start with the command followed by a semicolon for enter. Each time user input is required add a \ each time you need to add a response like Yes or TWist add it and every time you need to hit enter while executing that command add another semicolon. About Special Control Characters in Command Macros
    1 point
  8. have a look at this (setq fso (vlax-create-object "Scripting.FileSystemObject")) (setq drv (vla-get-drives fso)) (vlax-for what drv (vlax-dump-object what))
    1 point
  9. Printed right on the case.
    1 point
×
×
  • Create New...