TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: zoltan on March 24, 2006, 04:51:13 PM
-
...or am I reading this wrong?
_$ (rem 1.0 0.1)
0.1
_$ (/ 1.0 0.1)
10.0
:ugly: I'm so confused!
-
Looks like a bug to me. You may have to normalize the data so the divisor is an integer.
i.e. <oversimplied for simplicity/clarity> (apply 'rem (mapcar '(lambda (x) (* 10 x)) '(1.0 0.1)))
-
If you change the input to an integer, then it will output an integer.
hmm...
(Defun NewRem ( NUM1 NUM2 )
(/ (Rem (* NUM1 10.0) (* NUM2 10.0)) 10.0 )
)
is this going to solve it?
_$ (rem 0.1 0.01)
3.46945e-018
_$ (/ 1.0 0.01)
100.0
_$ (NewRem 1.0 0.1)
0.0
_$ (NewRem 0.1 0.01)
0.01
This is not looking too good.
Let's try this:
(Defun MyRem ( NUM1 NUM2 )
(- NUM1 (* NUM2 (Fix (/ NUM1 NUM2))) )
)
hmm..
edit: oops
-
It's back to the real number storage problem. For some reason (rem) rounds 1.0 down just a little bit. -David
Command: (rtos (rem 1.0 0.1) 2 16)
"0.1000000000000000"
Command: (rtos (rem (+ 1 1e-15) 0.1) 2 16)
"0.0000000000000011"
Command: (rtos (rem (+ 1 1e-16) 0.1) 2 16)
"0.1000000000000000"