home bbs files messages ]

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,307 of 264,096   
   Dan Cross to arne@vajhoej.dk   
   Re: basic BASIC question   
   31 Jan 25 22:05:31   
   
   From: cross@spitfire.i.gajendra.net   
      
   In article <679d26bd$0$713$14726298@news.sunsite.dk>,   
   Arne Vajhøj   wrote:   
   >On 1/31/2025 2:24 PM, Dan Cross wrote:   
   >> In article <679d001e$0$713$14726298@news.sunsite.dk>,   
   >> Arne Vajhøj   wrote:   
   >>> On 1/31/2025 11:39 AM, Dave Froble wrote:   
   >>>> On 1/31/2025 10:18 AM, Arne Vajhøj wrote:   
   >>>>> Is it common to use:   
   >>>>>   
   >>>>> declare integer constant TRUE = -1   
   >>>>> declare integer constant FALSE = 0   
   >>>>>   
   >>>>>   
   >>>>> ?   
   >>>>   
   >>>> It works.  Doesn't really matter if declared a constant.  Zero is false,   
   >>>> anything else is true.  Using 1 vs -1 has been more my experience.   
   >>>   
   >>> I got the impression that the manual/compiler prefer -1 over 1.   
   >>>   
   >>> print not 0%   
   >>>   
   >>> does print -1.   
   >>   
   >> This sort of makes some sense when one considers the bit   
   >> representation of `-1` on a 2s complement machine (all bits 1).   
   >   
   >True.   
   >   
   >But there is no consistency between languages.   
   >   
   >$ type dump.for   
   > [snip]   
      
   I don't know why this should be surprising?   
      
   For Pascal, the integer values of `true` and `false` are given   
   in the standards documents (from e.g., ISO/IEC 7185:1990(E) sec   
   6.4.2.2. para (c): "The ordinal numbers of the truth values   
   denoted by *false* and *true* shall be the integer values 0 and   
   1 respectively."   
      
   In C, the relevant standards and most historical compilers treat   
   0 as false and anything non-zero as true and the negation   
   operator turns 0 into a 1 (I'm not sure how far back this goes).   
      
   Treating -1 as true in BASIC seems rather common, from the quick   
   survey I did; I speculate that this is almost certainly due to   
   the bit representation of -1 having all bits set, while in BASIC   
   the integer type is (usually?) signed, thus -1 on a two's   
   complement machine.  I wonder what the original DTSS BASIC did?   
      
   	- Dan C.   
      
   --- 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