• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

how to avoid scientific notation

  • Thread starter Thread starter Gio_S
  • Start date Start date

Gio_S

Guest
Hello everyone,
I'm going crazy. I write on files, but for my convenience of analysis I would like to write always numbers in decimal notation.
instead, where for example there was rotation, and the number always approximated by the mobile comma, I find in the middle of the file some numbers in scientific notation.
And yet I use all the tricks. .
I repeat in the lisp the settings I already hold by default (setvar "lunits" 2) (setvar "luprec" 8). .
I promise to convert to string like this, for example (xn 2 8)but nothing to do! Every now and then he takes me out his good 4,44089210- 16 And the like!
I would kindly ask... Do I call anything or my autolisp on intellicad on this thing is clamorously bugged?
Thank you!
skirts
 
in autolisp:"....the real numbers are stored in double-precision mobile comma format, providing at least 14 significant precision figures, despite compaiano solo 6 in the autocad command line area."so if you have to view them you can use rtos, while in calculations for you nothing changes if in variables is stored 1.0e-05 instead of 0.00001
 
in autolisp:"....the real numbers are stored in double-precision mobile comma format, providing at least 14 significant precision figures, despite compaiano solo 6 in the autocad command line area."so if you have to view them you can use rtos, while in calculations for you nothing changes if in variables is stored 1.0e-05 instead of 0.00001
Right! That is my problem, rtos gives me a string in scientific notation even if with the topic of rtos I ask the decimal notation.
I do not know at this point whether it is a fault of my lisp or if it is generalized, in the sense that, however, when the point has many decimals (caused above all by the operations in mobile comma), the lisp me still returns it in scientific notation.
This thing brings me behind all the problem of float operations, which go to approximate with a set of decimals, and disturb me in the comparisons between strings.Exemplary:If you draw a cube using the tops always placed on coordinates between 0 and 1 (full numbers), you will have clean coordinates. I did the simplest example case.
but if you draw a face 0,0,0 - 0.1,0 - 1,1,0,0 (integer numbers) and from that first face cop and ruoti faces to create the cube, because of the operations in mobile comma, some one (inside) go to bless, especially in the calculation of normal, and you get instead decimals such from call back always scientific notation, even if I don't want it on text files.
the only way (scomodo) is to save in dxf asking only a few decimals (typically I ask 6), and at this point the float is truncated and back to the drawing with the clean points.
the same thing I could get with the rtos argument that asks eight decimals if however this argument did not ignore me and still gave me the mobile comma.
It's complicated to explain even though the concept is simple.
 
You mean I found the trick? without the transformation double internal carpiata does not work, but with that it seems to be
Code:
 (defun clea(a)
(setq between a)
(setq between (* between 1000)
(fix between)
(setq hh (rtos between 2 8) ; necessary!
(setq between (atof hh)
(if (= between 0)(setq between 0.0000001))
(setq between (/ between 1000)
)
in the main, every value to write is therefore first processed so
(Clear ax)(setq ax tra)
(Clear ay)(setq ay tra)
(clea az) (setq az tra) .... and exponential notation disappears in favor of rounding
 
ps ... there is a joke in the middle to avoid the division by zero in the calculation that will make to obtain the vectors of the normal
 
placed the code that improved, I find it important for both 3d printing and renderings.
I answer because.
in this type of drawings there is the need that the points used by these programs, if they must be equal they really are, while the cad, after operations in mobile comma (typically rotations) compromises its integrity.
also here on the forum I read topic that reported the problem for elements with non-perfect coincidence.
I'll explain, in a mesh stl a x = 13.7865000 is not equal at all 13.7864999, generated in the cad by mobile comma operations, and if the print program or render it rightly finds them different, it can draw wrong conclusions on the integrity of the mesh.
my problem was not only this, but also (see topic title) not having exponential notation, that cad propinates me occasionally on writing files, even when with rtos I declare that I don't want to. (first option declared to "two" (decimal note).

the only way to avoid it was to temporarily move the comma of three places. if I moved 4, with the *10000 then returned to / 10000, nothing to do the notation "and" stood out.
I so trunk the float (using the * and / only to 1000) exactly to three decimals, but that I am definitely enough, both on the 3d printing works, where my Unit to measure the assumo at the millimeter, both for the architecture, where I take the meter, and I certainly do not care about the tenth of a millimeter.

but there is another question, the autolisp truncated fix, not round.
I instead reducing to three decimals after the comma I want to approximate to the rounding closerAnd don't cut short. and I therefore added the routines that I believe appropriate since the round function in classic autolisp is not there.
so this function... that for now seems to act without errors.

It's probably redundant, but I prefer, and by the way I don't know if I understood the concept well, but it touches me "to recapture" the argument that I passed to the function from an internal variable to the function, because (I don't know if I'm wrong) but the defun only keeps in locale The changes I make him do to the subject I've been through.
When I come out of the dead, I find it as such and as I have passed it to the origin. from here, that is why I take from the "between" in the dead the new value processed locally. and I have to give it to the subject.
It's kind of a mess, but I don't know what you can do more elegantly. in case there is a method of the most sent type thank you...
I mean of the dead type I call(x) ... and out x will contain the new value I calculated in my name.. .
I did not succeed, the x variations always remain local to the function. . .
Code:
 (defun clean(a)
(setq between a)
(setq between (* between 1000)
(setq between (fix between)
(setq hh (rtos between 2 3))
(setq between (atof hh)
(setq between (/ between 1000)
; round procedure
(if) between 0 and positive
(progn)
(setq diff (- between)
(if) diff
(setq between (+ 0.001))
)
)
(progn)
(setq diff (- between)
(if (< diff -0.000)
(setq between (- between 0.001))
)
)
)
); end defun clean
in the main, every processed value, after the call to the dead, I have to recover it from "tra", processed within the function on a copy of ax, and reassign it to the topic
(clean ax)
(setq ax between)
but as I said I can't do anything else, because the ax argument is changed by the function, but only as a local variable.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top