Welcome, Guest. Please login or register.

Author Topic: AmigaBasic revisited  (Read 5031 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline FluffyMcDeath

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 3440
    • Show all replies
Re: AmigaBasic revisited
« on: February 18, 2003, 07:55:44 PM »
Quote


Does BASIC have a modulus anybody?


I think it's mod , but I'm not sure and can't remember how to use it if it is. However,

let n=25
...
if (x/n) = int(x/n) then
 blah blah blah

will do the same in AmigaBasic MOST of the time. Certainly for small numbers AmigaBasic was pretty good about rounding its floats. I'd stay away from it though because, while it may be mathematically correct, computers aren't.

Safer way, if you don't have mod is to just count:
if count > 0 then
{
  print char(x)
  count--
}
else
{
  print
  count = n
}




 

Offline FluffyMcDeath

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 3440
    • Show all replies
Re: AmigaBasic revisited
« Reply #1 on: February 18, 2003, 08:09:54 PM »
Oh well, just checked an online faq and there doesn't appear to be a mod operator.

Thomas' number 2 looks nice. But for speed, counting beats LEN$ ing.  Then again, if you want speed go C.