Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

Converting double to string creates inaccuracy

$
0
0

I have this interresting problem, it occured just here, in other situations, the script works fine.

 

I am counting length from coordinates:

 

Command: (setq bod1 ppo_bod1)
(-0.821965 -1.7232 0.0)

Command: (setq bod2 ppo_bod2)
(25.428 13.1268 0.0)

Command: !mfac
0.025

Command: (setq x (atoi (rtos(/ (abs (- (car bod2) (car bod1))) mfac))))
1050

Command: (setq y (atoi (rtos(/ (abs (- (cadr bod2) (cadr bod1))) mfac))))
593

Command: (- (cadr bod2) (cadr bod1))
14.85

Command: (/ (abs (- (cadr bod2) (cadr bod1))) mfac)
594.0

Command: (rtos(/ (abs (- (cadr bod2) (cadr bod1))) mfac))
"593.99999998"

Command: (atoi (rtos(/ (abs (- (cadr bod2) (cadr bod1))) mfac)))
593

 

As you can see, the conversion from 594.0 (real) to string causes an inaccuracy, which is strange, because the length really is 594.0


Viewing all articles
Browse latest Browse all 14319

Trending Articles