# [Coco] replicating bitwise operators in BASIC

Dave Philipsen dave at davebiz.com
Fri Sep 9 22:13:16 EDT 2016

```Sounds like something parents would say when you get in trouble!

Dave Philipsen

> On Sep 9, 2016, at 8:33 PM, Brett Gordon <beretta42 at gmail.com> wrote:
>
> Lol...thats a beautifully insane BASIC expression, Dave. !
>
>> On Sep 9, 2016 2:37 PM, "Dave Philipsen" <dave at davebiz.com> wrote:
>>
>> Well, ok, it doesn't have a specific operator called 'NAND'.  It has NOT
> and AND.  Therefore A NAND B is:  NOT (A AND B).
>>
>> Try this on your CoCo to computer XOR (it uses only NOT and AND, which is
> NAND):
>>
>> 10 A = 0: B = 0: GOSUB 100
>> 20 A = 1: B = 0: GOSUB 100
>> 30 A = 0: B = 1: GOSUB 100
>> 40 A = 1: B = 1: GOSUB 100
>> 90 STOP
>> 100 Q = NOT ( NOT ( NOT ( A AND B ) AND A ) AND NOT ( NOT ( A AND B ) AND
> B ) )
>> 110 PRINT "A = ";A;" B = ";B;" Q = ";Q
>> 120 RETURN
>>
>> This is not the shortest way to perform an XOR with the CoCo but it does
> demonstrate that an XOR can be performed with just NOT and AND (NAND).
>>
>>
>> Dave
>>
>>
>>
>>> On 9/9/2016 1:09 PM, Barry Nelson wrote:
>>>
>>> Well you could, if Extended Color Basic had a NAND operator. To my
> knowledge
>>> it does not.
>>>
>>>
>>>>
>>>>        Dave Philipsen dave at davebiz.com
>>>
>>> <mailto:coco%40maltedmedia.com
> ?Subject=Re%3A%20%5BCoco%5D%20replicating%20bi
> 40davebiz.com
>>> %3E>
>>> Fri Sep 9 13:19:10 EDT 2016
>>>
>>>
>>>>
>>>>         Well, actually NAND _is_ NOT and AND.  And you can actually do
> it
>>>
>>> all
>>>>
>>>>         with just NAND.
>>
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
```