Menu

Maths in GCBasic

Help
2008-02-02
2013-05-30
  • Nobody/Anonymous

    Thanks for the development work on this - it has solved a few headaches already for me!

    I have a quick question about division. I noticed in PICBasic you can divide with n/2 and get the remainder with n//8. n//8 doesn't seem to work in GCBasic and I couldn't see and Math/Maths function lists. I could really do with getting this remainder thing working - is there a way of doing this? Alternatively I could do something hairy like: n-8*int(n/8) but get an error doing this too.

    Sorry for the noob question but I'm not really used to low level programming.

    Thanks in advance,

    Dave

     
    • Hugh Considine

      Hugh Considine - 2008-02-02

      Use the % operator. For example,

      Temp = SomeVar % 3

      will return the remainder of SomeVar divided by 3. If you don't like using the % sign, you can use MOD as is the case in QBASIC/FreeBASIC.

      Unfortunately I've not updated the online help file since the last major release this time last year, so if you're using update.zip the help will not be quite up to date. There is a page at http://gcbasic.sourceforge.net/update.html which lists the changes/new features, but that didn't exist until a few months after the % operator and so doesn't list it.

       
    • Nobody/Anonymous

      OK. Thanks so much for the quick reply!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.