DIV - feature or what?

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

DIV - feature or what?

Post by KenDown »

Trying to track down a bug in a program I tried to test what I thought might be the error with the following little programs:

Code: Select all

      m%=0
      REPEAT
        IFm%DIV1000=0PRINT".";
        m%+=1
      UNTILm%=-2

Code: Select all

      m%=0
      REPEAT
        IFm%DIV1000=0PRINT".";
        m%-=1
      UNTILm%=2
Obviously both are loops that will never end. The interesting thing is that whether going up or down, DIV seems to stop working, even though the value of m% continues to be incremented or decremented. Has anyone else encountered this feature?
RichardRussell

Re: DIV - feature or what?

Post by RichardRussell »

KenDown wrote: Thu 02 Apr 2020, 15:36The interesting thing is that whether going up or down, DIV seems to stop working, even though the value of m% continues to be incremented or decremented. Has anyone else encountered this feature?
I don't understand what you mean by "stops working". Your program prints a dot when m% DIV 1000 is zero, i.e. when m% is less than 1000. So obviously the printout ceases as soon as m% is greater than +999 (or is less than -999), but nothing "stops working", the conditional test simply isn't met any more.

Perhaps you can explain in more detail what the "feature" is.
p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

Re: DIV - feature or what?

Post by p_m21987 »

Richard is right. The program is working exactly as it should.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: DIV - feature or what?

Post by KenDown »

Oh tarnation! Yes, you are right, DIV is working exactly as it should. My mistake was having a brainstorm and confusing DIV and MOD. And, of course, when MOD is substituted the programs go on printing dots ad infinitum.

Which means that I am still lost as to why my other program keeps crashing!