M
M
MDtox2018-06-11 19:35:17
Programming
MDtox, 2018-06-11 19:35:17

How to use bit operations in games?

Not strong in bitwise operations. In some games on github, I see that they use bit shifts there (mostly). Here is an example -> https://github.com/Jahmaican/jcaster/tree/master/class.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SagePtr, 2018-06-11
@MDtox

Shift right (>>) is a division by 2^n rounded down.
Shift left (<<) is a multiplication by 2^n
For example, x >> 1 is the same as x / 2 with rounding
x << 2 is the same as x * 4

G
GavriKos, 2018-06-11
@GavriKos

Well, about the same as the addition operator. And approximately for the same - to implement the intended logic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question