Login
Back to forumReply to this topicGo to last reply

Posted By

Litwr
on 2008-10-14
02:14:29
 YABE!

Thanks to SVS the Yet Another Basic Error was found. happy This is maybe the last. Try to evaluate 2^1^2 - it should be 2 but Basic gives 4. So Basic calculate this in inhuman way from left to right instead of right to left. However this is error common to almost all Basics.

Posted By

Crown
on 2008-10-15
06:28:21
 Re: YABE!

I don't see this as an error. This is standard behaviour.
For operators with the same precedence level the processing order is always left to right, this is why there are parenthesis, so that you can actually tell the system what exactly you wanted.

Posted By

Litwr
on 2008-10-20
04:24:29
 Re: YABE!

Yes this is not BASIC translator error - this is error in the BASIC syntax for the arithmetic expression. When
     2
  1
2 is calculated by human it gives 2! I can also add that the compilers patterns for YACC/BISON always set this operation as right associative. BTW try awk, bc, ... It is shame that men forced to use inhuman way to work with power even in the VB.

Posted By

Litwr
on 2008-10-20
06:48:13
 Re: YABE!

I also can add Perl, Python, ...

Posted By

Csabo
on 2008-10-20
09:38:44
 Re: YABE!

I thought power of should be left to right as well, but Wikipedia says otherwise:

http://en.wikipedia.org/wiki/Order_of_operations#Examples_from_arithmetic], see 2nd example.

So I guess technically you are correct, but I'm not sure if this really qualifies as a "bug". I mean it's not like they attempted to calculate this correctly and failed to program it right, I think they never even attempted to follow this rule.

Posted By

Litwr
on 2008-10-21
04:19:53
 Re: YABE!

I couldn't agree with famous programmer Edsger Dijkstra who said "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration *. But your words give me a point to his position. wink I don't know exactly whether this error presents in the first Basic of 60s or it is caused by insufficient education level of Bill Gates at 1975. However the Basic predecessor Fortran has correct power operation. Yes, this is *global* error but this is error because it breaks the mathematical rules!



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024