[LISP] Why is it like that? "1252.226" > 1252.23

[LISP] Why is it like that? "1252.226" > 1252.23

iBlachu
Advocate Advocate
195 Views
2 Replies
Message 1 of 3

[LISP] Why is it like that? "1252.226" > 1252.23

iBlachu
Advocate
Advocate

I want but can't get a numeric variable with the value 1252.226. It keeps rounding me up to 1252.23.

 

(setq a 1252.226)

!a

1252.23

(setq a (+ a 0.001))

!a

1252.23

 

How to get numerical variable 1252.23?

How to change this rounding?

0 Likes
196 Views
2 Replies
Replies (2)
Message 2 of 3

iBlachu
Advocate
Advocate

I guess you have to accept that the number displayed is different and its actual value is correct. When displaying, replacing it with a string will give you the desired precision effect.

 

(setq s "1252.226")
(setq a (atof s))

(print (rtos a 2 3))

(setq a (+ a 0.001))

(print (rtos a 2 3))

0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant

UNITS command controls displayed values:

Kent1Cooper_0-1670847465866.png

in things like the Properties palette, but I find not in that situation [which is a surprise to me].  But as suggested by @iBlachu, it "knows" the real value you put in.

 

Kent Cooper, AIA
0 Likes