bit-manipulation
Tell if a 32 bit signed int is a power of 2
I need to determine if a signed 32 bit number is a power of two. So far I know the first thing to do is check if its negative since negative numbers cannot be powers of 2.[详细]
2023-04-04 06:33 分类:问答Which algorithm is faster for checking if a bit is set?
I am making a game in which I am storing a lot of data in one integ开发者_如何学Goer or long, because I will have a massive amount of data.I don\'t want to use whole classes for performance reasons, a[详细]
2023-04-04 04:36 分类:问答Determine the sign of a 32 bit int
Using ONLY: ! ~ & ^ | + << >> NO LOOPS I need to determine the sign of a 32 bit integer and I need to return 1 if positive, 0 if 0 and -1 if negative.[详细]
2023-04-03 21:32 分类:问答Very simple masking
In 3 operations how can I turn a byte into a 32 bit int that matches this: 0x1fffe I can only explicitly access a byte at a time thus I start with 0xFF and then shift it.[详细]
2023-04-03 21:29 分类:问答How to multiply an int with a fraction
I need to multiply an int by a fraction using bitwise operators without loops and such. For example, I need to multiply by x by 3/8.[详细]
2023-04-03 21:08 分类:问答C# Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first
I know these warnings are probably pointless.. But anyway I could get rid of them? I got 7 of these warnings.[详细]
2023-04-03 16:24 分类:问答How to translate these hex numbers into bitwise values?
I\'m looking through the source code of a project written in C. Here is a list of options that are defined开发者_如何学Go (no these aren\'t the real defines...not very descriptive!)[详细]
2023-04-03 15:56 分类:问答4 signed bytes packed into a 32-bit unsigned
// Declaration of data type where 4 bytes are packed into an unsigned. int xbyte(packed_t word, int bytenum);[详细]
2023-04-03 09:40 分类:问答How can I combine 2 bits in a single field using an EnumSet?
Given a binary string coded on 1 byte, is it possible to map several of that byte\'s bits into an enum value ?[详细]
2023-04-03 00:34 分类:问答Problem with Bitwise Barrel Shift Rotate left and right in C#
In C++ I have code like this. static UInt32 rol(UInt32 value, UInt32 bits) { bits &= 31; return ((value << bits) | (value >> (32 - bits)));[详细]
2023-04-02 17:52 分类:问答