Re: basic BASIC question

Liste des GroupesRevenir à co vms 
Sujet : Re: basic BASIC question
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.os.vms
Date : 31. Jan 2025, 23:05:31
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vnjhfb$gk1$1@reader2.panix.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <679d26bd$0$713$14726298@news.sunsite.dk>,
Arne Vajhøj  <arne@vajhoej.dk> wrote:
On 1/31/2025 2:24 PM, Dan Cross wrote:
In article <679d001e$0$713$14726298@news.sunsite.dk>,
Arne Vajhøj  <arne@vajhoej.dk> 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.


Date Sujet#  Auteur
31 Jan 25 * basic BASIC question62Arne Vajhøj
31 Jan 25 +* Re: basic BASIC question3Robert A. Brooks
31 Jan 25 i`* Re: basic BASIC question2Arne Vajhøj
31 Jan 25 i `- Re: basic BASIC question1Chris Townley
31 Jan 25 +- Re: basic BASIC question1jeffrey_dsi
31 Jan 25 +* Re: basic BASIC question35Dave Froble
31 Jan 25 i+* Re: basic BASIC question33Arne Vajhøj
31 Jan 25 ii+* Re: basic BASIC question30Dan Cross
31 Jan 25 iii+* Re: basic BASIC question27Arne Vajhøj
31 Jan 25 iiii+* Re: basic BASIC question11Dan Cross
1 Feb 25 iiiii+* Re: basic BASIC question2Craig A. Berry
1 Feb 25 iiiiii`- Re: basic BASIC question1Arne Vajhøj
1 Feb 25 iiiii`* Re: basic BASIC question8Arne Vajhøj
1 Feb 25 iiiii +* Re: basic BASIC question6Arne Vajhøj
1 Feb 25 iiiii i`* Re: basic BASIC question5Arne Vajhøj
1 Feb 25 iiiii i +- Re: basic BASIC question1Dan Cross
2 Feb 25 iiiii i `* Re: basic BASIC question3Craig A. Berry
2 Feb 25 iiiii i  `* Re: basic BASIC question2Arne Vajhøj
2 Feb 25 iiiii i   `- Re: basic BASIC question1Dan Cross
1 Feb 25 iiiii `- Re: basic BASIC question1Dan Cross
31 Jan 25 iiii`* Re: basic BASIC question15Arne Vajhøj
2 Feb 25 iiii +- Re: basic BASIC question1Lawrence D'Oliveiro
3 Feb 25 iiii `* Re: basic BASIC question13Simon Clubley
3 Feb 25 iiii  `* Re: basic BASIC question12Arne Vajhøj
3 Feb 25 iiii   +* Re: basic BASIC question10Lawrence D'Oliveiro
4 Feb 25 iiii   i`* Re: basic BASIC question9Arne Vajhøj
4 Feb 25 iiii   i +* Re: basic BASIC question7Lawrence D'Oliveiro
4 Feb 25 iiii   i i`* Re: basic BASIC question6Arne Vajhøj
4 Feb 25 iiii   i i +* Re: basic BASIC question2Lawrence D'Oliveiro
5 Feb 25 iiii   i i i`- Re: basic BASIC question1Arne Vajhøj
5 Feb 25 iiii   i i `* Re: basic BASIC question3Lawrence D'Oliveiro
5 Feb 25 iiii   i i  `* Re: basic BASIC question2Arne Vajhøj
5 Feb 25 iiii   i i   `- Re: basic BASIC question1Lawrence D'Oliveiro
4 Feb 25 iiii   i `- Re: basic BASIC question1Dan Cross
5 Feb 25 iiii   `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 iii`* Re: basic BASIC question2Chris Townley
31 Jan 25 iii `- Re: basic BASIC question1Dan Cross
1 Feb 25 ii`* Re: basic BASIC question2Dave Froble
1 Feb 25 ii `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 i`- Re: basic BASIC question1Chris Townley
31 Jan 25 +* Re: basic BASIC question20Simon Clubley
31 Jan 25 i+* Re: basic BASIC question17Arne Vajhøj
31 Jan 25 ii`* Re: basic BASIC question16Arne Vajhøj
31 Jan 25 ii +* Re: basic BASIC question14Dan Cross
3 Feb 25 ii i`* Re: basic BASIC question13Simon Clubley
3 Feb 25 ii i +* Re: basic BASIC question2John Dallman
3 Feb 25 ii i i`- Re: basic BASIC question1Lawrence D'Oliveiro
3 Feb 25 ii i +- Re: basic BASIC question1Dan Cross
6 Feb 25 ii i `* Re: basic BASIC question9Arne Vajhøj
6 Feb 25 ii i  +- Re: basic BASIC question1Arne Vajhøj
6 Feb 25 ii i  +* Re: basic BASIC question5Dan Cross
6 Feb 25 ii i  i`* Re: basic BASIC question4Arne Vajhøj
6 Feb 25 ii i  i +- Re: basic BASIC question1Dan Cross
6 Feb 25 ii i  i `* Re: basic BASIC question2Lawrence D'Oliveiro
7 Feb 25 ii i  i  `- Re: basic BASIC question1Arne Vajhøj
6 Feb 25 ii i  `* Re: basic BASIC question2Lawrence D'Oliveiro
7 Feb 25 ii i   `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 ii `- Re: basic BASIC question1Lawrence D'Oliveiro
1 Feb 25 i`* Re: basic BASIC question2Dave Froble
3 Feb 25 i `- Re: basic BASIC question1Simon Clubley
2 Feb 25 +- Re: basic BASIC question1Lawrence D'Oliveiro
2 Apr 25 `- Re: basic BASIC question1Johnny Billquist

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal