Login
Back to forumReply to this topicGo to last reply

Posted By

SVS
on 2018-08-21
07:12:55
 9^2 bug

Hi,
I (re)discovered this bug, did you know it before?
If not type in "? 9^2 [return]"

P.S. - My very first pocket calculator had the same bug when you hit the key [x^y] with 9^2 happy happy
(It was CASIO not CBM).
P.S.2 - The same with 3^4.

Posted By

Csabo
on 2018-08-21
08:37:18
 Re: 9^2 bug

That's cool, but it's not exactly a bug, just the fact that floating point operations are inherently inaccurate.

How about this, I think it's even funnier. Ever seen the Plus/4 claim that 3 is not equal to 3? happy

0 A=3 : B=5 : C=A/B : C=C*B
1 PRINT A;
2 IF A=C THEN PRINT"=";:ELSE PRINT"<>";
3 PRINT C;

Result: 3 <> 3. Try it with other number pairs, most will be just fine, but for some (especially multiplies of 3, as you've noticed), there's some internal rounding error. It's normal, even JavaScript has a similar issue.

Posted By

Charlemagne
on 2018-08-21
09:44:34
 Re: 9^2 bug

Hi Csabo,

I tried it in Turbo Vision 4 BASIC and it said the answer:

3<>2.9999994

happy

So, C=2.9999994... It comes from the storage of variables in memory, not so accurate.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon