Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.os.vms    |    DEC's VAX* line of computers & VMS.    |    264,096 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 262,598 of 264,096    |
|    Johnny Billquist to All    |
|    Re: basic BASIC question    |
|    02 Apr 25 17:37:38    |
      From: bqt@softjar.se              On 2025-01-31 16:18, Arne Vajhøj wrote:       > Is it common to use:       >       > declare integer constant TRUE = -1       > declare integer constant FALSE = 0       >       >       > ?              After reading through this thread, I can offer a comment or two that       I've not seen anyone else bring up (and sorry for reviving a thread that       had stopped).              But first of all, while I haven't often seen those declarations as such,       they make perfect sense in BASIC.              What noone seems to have brought up is that BASIC don't really have a       boolean type, or logical operations on booleans.              There is no boolean AND for instance. There is only the numerical one.              If you do a statement like:              IF 1% AND 2% THEN PRINT "All true" ELSE PRINT "All false"              you'll get "All false".              Because while 1 and 2 both will be regarded as true (or rather not       false), AND isn't dealing with them that way. It just does a binary and       of the two values, and then you have an IF on the resulting value (which       would be 0 in this case).              So in that sense, it is good practice to use -1 for true, because then       at least TRUE and (whatever not false) is still (sortof) true.              It's also easy to observe that BASIC actually generally use -1 to       represent true.              Just try:              PRINT 1=1              for example. The output will be -1.              Here are the cut-n-paste from BASIC+2 for this:              .bp2              PDP-11 BASIC-PLUS-2 V2.7-C              BASIC2              print 1=1                     -1              BASIC2              IF 1% AND 2% THEN PRINT "All true" ELSE PRINT "All false"                     All false              BASIC2                             Johnny              --- SoupGate-DOS v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca