Bitwise Operators?

Hola Thunkadors,

I searched for “bitwise” in the X forum, but found nothing so I hope someone can help me. I did find a related post, but it is clearly not for X.

I’d like to do bitwise operations between two numbers. For those who don’t know about bitwise operators, you can read about them here.

Of course, I tried the boolean operator blocks, but they wouldn’t accept numbers as parameters. Any other suggestions?

Thanks in advance!


Blocks of logical operations understand numbers. To do this, use variables.

Thunkable X has partial support for working with numbers in hexadecimal and binary form. You can see more details on the page when studying the type of number. To work with hexadecimal numbers, you can also use blocks for working with color.

Hi AC,

Thanks for that and there is some useful information there, but I still cannot do a bitwise and with 2 numbers. Using the boolean AND, if the first number is non-zero the result is the contents of the second operand. E.g…

x = 1, y = 1: x AND y = 1 (correct)
x = 63, y = 1: x AND y = 1 (correct)
x = 1, y = 63: x AND y = 63 (incorrect)

Thanks in advance for any other suggestions!

You cannot do bitwise operations using logical operations. Here you have to think hard - translate numbers into binary format, and then use the blocks to work with texts to select the desired bit and perform a logical operation with it

Haha, that’s not a problem. I’ve been doing binary/octal/hexadecimal since 1977. I just don’t see the point since every modern programming/scripting language can do bitwise operations.

It is such a basic building block for so many other things that I am having difficulty believing it was not included in Thunkable at the same time as the basic arithmetic operators. Hopefully it will soon be available.

Thank you!

Unfortunately, when working with Thunkable X, you’ll have to create many things manually, even if that doesn’t make sense. ) If you know how to program, then it will be interesting for you to work with Thunkable X and come up with functionality that is not in it.

But I don’t have time to create functionality which is not portable. I would do it if it could be copy/pasted or otherwise imported into another project. Also, if the project were open source, I’d be happy to work on the code to create new additional functions.

I’m afraid to disappoint you in that Thunkable X is no possibility of any work with the code or copy blocks between projects, or to get basic functionality in terms of which provide programming languages.

Yet :grin:

Exactly Brian! We’ve been working hard on adding this sort of functionality for a while now and it will dramatically improve your workflow once released.

But, as @actech suggests, you shouldn’t let that stop you from trying out things now either! :grinning:

1 Like