Has anyone used the bitwise operators on Teletype to store multiple pieces of data in each cell? I’m working on a scene using the grid integration where i’d like to maximize the number of patterns I can switch between and since I’ve got the grid to visualize the data in the pattern view, I figured I could maximize the storage by stuffing those bits (sorry prob not the correct term).

The first piece of data is a division between 0-32 (inclusive) so that needs 6 bits. The next piece of data is an offset between 0-16 (inclusive) so that’s another 5 bits. The last is between 1-4 so that’s another 3 bits.

The pattern cells hold values between -16384 and 16384 so I think that means there are 15 bits used to store them? 6 + 5 + 3 = 14 so theoretically this should be possible right?

I guess what it comes down to is the syntax for stuffing and unstuffing the individual pieces. My bitwise operation skills are basically non-existant, but I suspect with the limits on space in a TT script, it might be prohibitive.

Can anyone demonstrate what this code might look like?

it’ll be much easier once we have the dedicated bitwise ops, but yeah, you can do it now. you can store 16 bits (the range is actually -32768…32767), in most cases you can just treat it like an unsigned 16 bit integer (not sure if RSH / LSH are signed or not, so that’s something to be aware of if using these ops).

Here, 63 is a mask to isolate the first 6 bits (63 = 0b111111).

More fields will require more careful usage. A field in the “middle” will require a shift as well as a masking AND.

As the numbers are signed, I would simply avoid using the most significant bit at all if you are counting on doing math with the numbers. Poking the top bit will screw with the results of your RSH. It won’t be a problem if you always AND mask the top field when extracting, though, I think.

Also, don’t try to store negative numbers this way.