[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Kyan Pascal question
- Subject: Re: Kyan Pascal question
- From: "David Wilson" <mcs6502@gmail.com>
- Date: 8 Jul 2006 04:59:57 -0700
- Complaints-to: groups-abuse@google.com
- Injection-info: h48g2000cwc.googlegroups.com; posting-host=220.233.163.88; posting-account=v7oSuQ0AAAAZLwd761jftD5qph4UbWwl
- Newsgroups: comp.sys.apple2
- Organization: http://groups.google.com
- References: <44af49ac$0$884$ba4acef3@news.orange.fr>
- User-agent: G2/0.2
- Xref: g2news2.google.com comp.sys.apple2:10170
Guillaume Tello wrote:
> Hello,
>
> I want to test individual bits into an integer, for example, bit 3 in A
> with:
> var
> A,B:integer;
>
> begin
> B:=A and 8;
> ...
>
> And I expect, if A=12 to get B=8 and if A=7, to get B=0.
>
> But, this doesn't work. Are those operators (OR, AND, NOT) reserved for
> boolean values?
Yep, just like in Applesoft BASIC the AND and OR operators are boolean
rather than bitwise but they do work on all 16 bits. Looking at page
III-100..103 of the Apple Pascal 1.3 manual we find:
INTEGER to BOOLEAN: ODD(X)
BOOLEAN to INTEGER; ORD(X)
BOOLEAN to CHAR: CHR(ORD(X))
Change case of character C
MASK := ODD(32);
C := CHR(ORD((MASK AND NOT ODD(ORD(C))) OR (NOT MASK AND ODD(ORD(C)))));