What is this BASIC?

I fully expect downvotes, but I became very curious, and I hope someone can answer. Our discrete mathematics professor really loves old languages ​​for the many bitwise operators that they provide. Now he gave us homework, which was to determine the output of the following BASIC expression:

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

I solved this, and I'm pretty sure it should output -105, but I wanted to compile it to make sure. Then I realized that I was facing a problem. I have no idea what BASIC is! The compiler for the source language BASIC could not compile it. The QBasic compiler could not compile it. the VB.NET compiler could not compile it, even after I changed it to what I think should be the VB.NET syntax as follows:

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

The question arises: is there even a BASIC species or dialect in which a program with this statement can be compiled? And if so, which one?

+4
source share
3 answers

This works in the "original" Microsoft Visual Basic. The version of VB.NET is not completely compatible.

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

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

There are also other possible basic dialects that will work perfectly - PowerBASIC may be one of them, but I can’t really check.

, , - , .

+3

, VBA.

, MS-Excel.

Sub VBA_Function()
    Dim x
    x = (Not (15 Or 51) Eqv 85) Imp (15 And 51)
    Range("A1").Value = x
End Sub
+1

Perhaps your professor asked the question specifically in this form as a challenge to solve it analytically, and not by entering code into the compiler. This is not a complicated expression.

Neither EQV nor IMP supports BASIC functions (so much for MS is always compatible with feedback!).

To confirm your answer, you must use function definitions and solve them manually.

The failure of this, it is interesting, is still supported in VBA. You can find VBA in most MS Office applications.

+1
source

All Articles