Using Arithmetic Instead of Logical Operators in Commodore Basic @JosipRetroBits
Using Arithmetic Instead of Logical Operators in Commodore Basic  @JosipRetroBits
Uploaded August 2023 | Updated November 2026, 3 hours ago
In this video, I tested a couple of different solutions for joining two conditions in IF statements on a Commodore 64. The idea for this video came from a Facebook post to use arithmetic instead of logical operators in if statements. The goal was to compare those solutions and see which one is the fastest one.

☕ If You like this video you can buy me a coffee: ko-fi.com/josipretrobits ☕

METHODS:
==============
1 if a=0 and b=0 then
2 if a=0 then if b=0 then
3 if (a=0)*(b=0)=1 then
4 if a*a+b*b=0 then
5 if abs(a)+abs(b)=0 then

TEST CASES:
==============
1 A is equal to 0, B is equal to 0
2 A is not equal to 0, B is not equal to 0
3 A is equal to 0, B is not equal to 0
4 A is not equal to 0, B is equal to 0


TEST CODES:
==============
0 rem arithmetic check
10 s=ti:a=5:b=5
20 fori=1to200
30 if a*a+b*b=0 then c=c+1
40 next
50 df=ti-s
60 print df,c

0 rem abs sum check
10 s=ti:a=5:b=5
20 fori=1to200
30 if abs(a)+abs(b)=0 then c=c+1
40 next
50 df=ti-s
60 print df,c

0 rem equal to, operators
10 s=ti:a=5:b=5
20 fori=1to200
30 if (a=0)*(b=0)=1 then c=c+1
40 next
50 df=ti-s
60 print df,c

0 rem nested if's
10 s=ti:a=5:b=5
20 fori=1to200
30 if a=0 then if b=0 then c=c+1
40 next
50 df=ti-s
60 print df,c

0 rem classic if and
10 s=ti:a=5:b=5
20 fori=1to200
30 if a=0 and b=0 then c=c+1
40 next
50 df=ti-s
60 print df,c


CHECK OUT:
==========
8Bit Retro ReFix @8BitRetroReFix
Captain Commodore @CaptainCommodore
Retro4u @Retro4u
YARC - Yet Another Retro Channel @YARC-1981
8bitsinthebasement @8bitsinthebasement


CHECK OUT MY OTHER COMMODORE/ACORN VIDEOS:
==========================================
đŸ•šī¸ Commodore 64 Programming: youtube.com/playlist?list=PLT0ijfj8mLN7G_Et0DGaVxcVK3N2EpnYk
đŸ•šī¸ Commodore 64 Hardware Videos: youtube.com/playlist?list=PLT0ijfj8mLN6JTkWianAanzEgLCaA0zFE
đŸ•šī¸ Commodore 64 Plus/4 Videos: youtube.com/playlist?list=PLT0ijfj8mLN7ioE3wBPYsu32V6Vs9goib
đŸ•šī¸ Acorn Electron Videos: youtube.com/playlist?list=PLT0ijfj8mLN5n1GNlJPZn3CW7o3hRf7Jv
đŸ•šī¸ Commodore 64 Games and Demos: youtube.com/playlist?list=PLT0ijfj8mLN6yuzbYo6MnQifgUEM08t83
đŸ•šī¸ The Pong Game Projects: youtube.com/playlist?list=PLT0ijfj8mLN6QqB1wxCWv7ERaw0fo44kB

#c64 #commodore #basic #programming #ifs #8bit #retrocomputing #arithmetic
Using Arithmetic Instead of Logical Operators in Commodore BasicA Twisted Christmas II, 1989 | Commodore 64 Greetings CardGO RUN on Commodore 64Dumpster Dive Asus PC, should I keep it?Morse Code Keyer and Commodore 64 | Part OneLive Stream #8 - Youtube Retro RepairersFlooder | Commodore 64 GamePlasma Effect in BASIC on Commodore64How to hide lines in Commodore Basic | Structure of Basic code in MemoryHow to build a Christmas card on Commodore 64Empire Strikes Back | C64 Fan version | Commodore 64Amazing old technology solutions. Easy fridge opening
Josip Retro Bits |

Using Arithmetic Instead of Logical Operators in Commodore Basic

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER