Sujet : Re: basic BASIC question
De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj)
Groupes : comp.os.vmsDate : 31. Jan 2025, 20:38:37
Autres entêtes
Organisation : SunSITE.dk - Supporting Open source
Message-ID : <679d26bd$0$713$14726298@news.sunsite.dk>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
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
subroutine dump(v)
integer*4 v
write(*,*) v
end
$ for dump
$ type logfun.for
program logfun
call dump(.true.)
call dump(.false.)
end
$ for logfun
$ link logfun + dump
$ run logfun
-1
0
$ type logfun.pas
program logfun(input,output);
[external]
procedure dump(%ref v : boolean); external;
begin
dump(true);
dump(false);
end.
$ pas logfun
$ link logfun + dump
$ run logfun
1
0
Arne