|
Post by C128Man on May 25, 2016 7:36:19 GMT
Hi,
I have a strange behavior with the INT() function.
With the program:
10 a=197 20 d=a/10^3 30 for i=1 to 3 40 d=10*d 50 print d 60 next i 70 end Everything works fine. The different values of D are: 1.97, 19.7, 197
But if I modify the code like this:
10 a=197 20 d=a/10^3 25 print d 30 for i=1 to 3 40 d=10*d:e=int(d):d=d-e 50 print d;e 60 next i 70 end The results are a bit strange!
.197 .969999999 1 .699999992 9 .999999918 6
Is it a bug in the INT() function?
Ben
|
|
|
Post by VDC 8x2 on May 25, 2016 15:30:23 GMT
It could be basic rounding numbers off behind the scenes.
|
|
|
Post by C128Man on May 27, 2016 7:28:38 GMT
Yes, maybe. I do the test in C on linux, I get the same problem. It's strange, on my Sharp PC1211 or Casio PB-100 (yes, it's very old PC), everything works fine.
|
|
|
Post by C128Man on Jun 1, 2016 12:53:13 GMT
I don't know if someone is interested.
It seems that the problem is during the multiplication on the line 40. I modify it and now, it works
40 d=10*d+1*10^-b
|
|