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

accuracy of a number

  • Thread starter Thread starter Angelo2449
  • Start date Start date

Angelo2449

Guest
Hello everyone,
I can't control the comparison between two numbers because, I think, of the accuracy due to the approximation:
Code:
..... . . . . . . ... ... ... ... 3313.1139,431.0565
xxxxxxxxxxxxxxxxxxxxxxxx 431.0565
xxxxxxxxxxxxxxxxxxxxx 431.057
< is returned with three decimals (431.057) while the incoming data
> (substr ele1 (+ pos1 2)) < has four characters after point (431.0565).
How can I have more decimals?
variables are thus set :
(setvar "dimdec" 8)
(Setvar "luprec" 4)
Thank you.
 
atof does not create any approximation:
(setq v "431.0565")
(Sectq) c (atof v) -> 431.057 (view 3 decimals)
(setq c1 (rtos) c 2 4) -> "431.0565"
So, c has 4 decimal digits.
to compare real numbers (double accuracy) uses equal indicating how many decimal figures consider.
 
I solved my problem by stabilizing the value of the number used as a comparison:
Code:
 (setq cadrzeros (rtos (cadr poszero) 2 4))
(setq cadrzero (atof cadrzeros)); comparison number
......
......
(if (< (tof (substr ele1 (+ pos1 2))) cadrzero) ; so the comparison always works
 

Forum statistics

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

Members online

No members online now.
ciao
Back
Top