Reputation: 454
How would I retrieve "face" from "i"?
int i = (id | (face << 16) | (type << 18))
Thanks!
Upvotes: 0
Views: 61
Reputation: 310859
You wouldn't, unless you can guarantee that it's only 2 bits wide, and that id
is only 16 bits wide, in which case all you have to do is right-shift and mask. Is this a trick question?
Upvotes: 1
Reputation: 14642
So, given the restriction that id is only 16 bits wide and that face is only 2 bits wide, use:
face = (i >> 16 ) & 3
Upvotes: 1