Bitwise operations in gimkit

1101010110101011010101101010110
100110010011001001100100110010
11010001101000110100011010001
But it still doesn’t work

2 Likes

Each number is 32 bits. There are extra 0’s at the front that binary translators wont show you.

1 Like

So it’s actually something like:
01101010110101011010101101010110
00100110010011001001100100110010
00011010001101000110100011010001

1 Like

Oh! So thats why they don’t line up.

2 Likes

Can someone give me a simple version of what yall are talking about so i can help?

1 Like

Um… I don’t know if it gets simpler than this…

1 Like

That is basically the simplest version. I’ve been stalking this conversation for a long time and it’s getting more interesting and over my head at the same time.

2 Likes

Maybe explain what binary is? I can’t since I’m on mobile

2 Likes

I’m storing pixels as 1s and 0s, so like: 101010 = :white_circle: :black_circle: :white_circle: :black_circle: :white_circle: :black_circle:.
I’m trying to set one of the pixels 1 one with the following bitwise operations:

(1 << k) | n

where k is the bit, and n is the number.
Anyway I’m just trying to do that.

2 Likes

You would use or for that, right?

2 Likes

Yeah. What the math does is this:
First, the starting pixels:
10100000
Then, it makes a new number with only the pixel it wants to place:
00001000
Then, it ORs the numbers together to get the final result:
10101000

1 Like

I’m about to go to my next block in school, where I have actual work to do, and not just some language study, so I’m gonna be mainly offline in a few minutes. If you have any questions/comments/ideas, post them and I’ll see them at around 11:10 EST.

1 Like

Ok.

2 Likes

If we can truncate numbers, then bitwise operations are easier to do in Gimkit.

1 Like

I don’t understand code, nor block code. So non of this makes any sense.

1 Like

Ok. So you know our base 10 system that we use? Take 465 for example. The 4 represents 4 100s, because it is in the 3rd spot. Each consecutive digit (starting at the right) represents a larger power of 10 (10^position-1), and the 1st position represents 1. Binary is the same but with 2. So in Black Hole’s system, a 0 represents an empty pixel, and a 1 represents a filled in pixel (white).

3 Likes

Oh, ok that makes more sense, thanks for explaining it the way people who don’t know it can understand it.

1 Like

You’re welcome. :grinning:

1 Like

Use this to understand bitwise operations:

1 Like

Ok, thanks.

2 Likes