[Coco] replicating bitwise operators in BASIC

James Jones jejones3141 at gmail.com
Sat Sep 10 20:06:31 EDT 2016


Thanks--you answered one of the questions I had. I'll have to fire up an
emulator and see what Color BASIC does with

X = 1.5
Y = 3.25
PRINT X AND Y

On Sat, Sep 10, 2016 at 7:02 AM, Johann Klasek <johann+coco at klasek.at>
wrote:

> 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.
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list