Search code examples
bitwise-operatorsbasicqbasic

What kind of BASIC is this?


I fully expect downvotes, but this got me really curious, and I hope at least someone can answer. Our discrete mathematics professor really likes old languages for the plethora of bitwise operators they provide. Now, he gave us a homework which was to determine the output of the following BASIC statement:

PRINT (NOT (15 OR 51) EQV 85) IMP (15 AND 51)

I've solved it and I'm pretty much sure it's supposed to output -105, but I wanted to compile it just to make sure. Then I figured out I was facing a problem. I have no idea what kind of BASIC is this! A compiler for the original BASIC language failed to compile it. A QBasic compiler failed to compile it. a VB.NET compiler failed to compile it, even after I modified it to what I think should be VB.NET's syntax like this:

Console.WriteLine((NOT (15 OR 51) EQV 85) IMP (15 AND 51))

The question is: is there even a sort or dialect of BASIC in which a program with this statement can compile? And if yes, which?


Solution

  • This works in the "original" Microsoft Visual Basic. The VB.NET version isn't exactly fully compatible.

    The easiest way you can try this is by using Visual Basic for Applications, which you can find in Microsoft Office. Indeed, the expression evaluates to -105. I've used Excel with this code:

    Cells(1, 1).Value = (Not (15 Or 51) Eqv 85) Imp (15 And 51)
    

    There's also probably other Basic dialects that wil work fine - PowerBASIC might be one of them, but I can't really check :)

    Identifying the exact dialect is tricky without knowing your teacher's background - there's a lot of those, and many are very similar.