How To

can I use bitwise operation?

3

R! 2022-11-15 06:26

I wanna use bit wise operation like this…

110→6
2→10

If I can do this, please tell me how to.


uncodem 2022-11-15 12:15 (Edited)

Can you elaborate? If you mean converting an integer into a binary string, you can use BIN$ for conversion from regular number into a binary string like 2->10. You probably have to make your own solution if you want to convert binary strings into regular numbers like in this example...


example.nx | Open in app
2022-11-15 12:15

was8bit 2022-11-15 18:35 (Edited)

Lowres can convert different number formats into base 10 by using the different base symbols, however lowres will not convert to any other base...


was8bit 2022-11-16 06:17

PRINT so, type this code, and run it...

PRINT %10
PRINT %110

It will show..

2
6


SP4CEBAR 2022-11-17 21:29 (Edited)

To convert a binary string into a number you could could do:


B$="110"
CALL UN_BIN(B$,V)


SUB UN_BIN(B$,V)
FOR I=1 TO LEN(B$)
ADD V,MID$(B$,I,1) * 2^(I-1)
NEXT I
END SUB




note: if "LEN(B$)" is "0" then the FOR loop won't run: it'll be skipped


Log in to reply.