[Coco] replicating bitwise operators in BASIC
Johann Klasek
johann+coco at klasek.at
Sat Sep 10 08:02:07 EDT 2016
On Sat, Sep 10, 2016 at 01:04:37AM -0500, Dave Philipsen wrote:
> Anything over 15 bits gives an ?FC ERROR
>
> ex: PRINT 32768 AND 3
> ?FC ERROR
In signed representaton 32768 ($8000)has to written as -32768
You may convert values >32768 (< 65536) by subtracting
65536 into signed 16 bit values (as float value ECB is using).
100 REM U16 TO S16 - SUB. 65536 IF TO GREAT
110 V = V + 65536*(V > 32767)
120 RETURN
200 REM S16 TO U16 - ADD 65536 IF NEGATIVE
210 V = V - 65536*(V < 0)
220 RETURN
or use defined functions ...
10 DEF FN US(V)=V+65536*(V>32767)
20 DEF FN SU(V)=V-65536*(V<0)
Johann K.
More information about the Coco
mailing list