Tag: bit-manipulation

2154 How do you set, clear, and toggle a single bit? 2008-09-07T00:42:17.500

1230 What are bitwise shift (bit-shift) operators and how do they work? 2008-09-26T19:47:15.367

783 How to count the number of set bits in a 32-bit integer? 2008-09-20T19:04:38.837

375 What is “2's Complement”? 2009-06-26T15:21:38.650

292 Extracting bits with a single multiplication 2013-01-27T11:58:23.600

224 Most Efficient Algorithm for Bit Reversal ( from MSB->LSB to LSB->MSB) in C 2009-04-14T02:48:46.230

193 Most common C# bitwise operations on enums 2008-09-18T15:46:20.073

189 What is the meaning of double tilde (~~) in Java? 2015-04-19T23:08:23.640

183 What does (x ^ 0x1) != 0 mean? 2013-12-19T10:49:02.030

162 Using bitwise OR 0 to floor a number 2011-09-20T15:47:08.357

160 What does a tilde do when it precedes an expression? 2012-09-06T12:02:25.003

153 ~x + ~y == ~(x + y) is always false? 2012-06-20T02:13:16.820

147 Rounding up to next power of 2 2009-01-21T17:26:18.103

143 C# int to byte[] 2009-08-23T16:22:09.743

138 Why does this random value have a 25/75 distribution instead of 50/50? 2014-12-23T17:57:41.097

123 How can I remove a flag in C? 2010-10-13T02:01:26.017

122 Why is XOR the default way to combine hashes? 2011-05-04T20:07:13.757

118 Should I use #define, enum or const? 2008-09-21T22:49:05.373

118 What is Bit Masking? 2012-05-08T06:07:28.693

106 Explain the use of a bit vector for determining if all characters are unique 2012-02-04T15:10:40.340

105 Are the shift operators (<<, >>) arithmetic or logical in C? 2008-08-11T08:55:13.277

102 What is the fastest/most efficient way to find the highest set bit (msb) in an integer in C? 2009-03-22T23:37:22.877

98 Position of least significant bit that is set 2009-04-16T16:54:48.300

94 Difference between 'and' (boolean) vs. '&' (bitwise) in python. Why difference in behavior with lists vs numpy arrays? 2014-03-25T21:18:23.617

93 Precedence and bitmask operations 2014-02-23T22:10:53.030

88 C/C++ check if one bit is set in, i.e. int variable 2009-02-07T13:10:46.953

86 In C/C++ what's the simplest way to reverse the order of bits in a byte? 2010-04-08T19:32:07.743

85 Bitwise operation and usage 2009-11-17T04:37:05.827

84 How do I get bit-by-bit data from an integer value in C? 2010-02-12T04:51:48.463

84 Why if (n & -n) == n then n is a power of 2? 2011-09-13T16:44:36.003

79 C/C++: Force Bit Field Order and Alignment 2009-09-29T01:07:10.760

79 Subtract/add value without overflow or underflow 2015-11-02T15:35:53.110

78 Incrementing 'masked' bitsets 2017-06-26T19:14:47.680

76 Have you ever had to use bit shifting in real projects? 2009-02-06T15:10:04.187

74 How can I multiply and divide using only bit shifting and adding? 2010-05-05T19:35:22.700

74 What is CHAR_BIT? 2010-07-08T05:49:41.513

73 Explain this snippet which finds the maximum of two integers without using if-else or any other comparison operator? 2011-01-23T07:39:45.213

72 Given an integer, how do I find the next largest power of two using bit-twiddling? 2009-08-24T13:43:01.813

71 What's the simplest way to test whether a number is a power of 2 in C++? 2008-09-20T14:33:59.580

71 Best practices for circular shift (rotate) operations in C++ 2009-04-22T10:20:46.853

71 Set specific bit in byte 2011-01-12T21:00:05.693

67 How does XOR variable swapping work? 2008-10-30T06:37:58.320

65 Efficiently find binary strings with low Hamming distance in large set 2011-06-17T18:01:41.723

62 Bitwise operators and "endianness" 2009-06-24T23:55:22.787

61 Is shifting bits faster than multiplying and dividing in Java? .NET? 2009-07-22T21:43:21.997

60 How do I flip a bit in SQL Server? 2008-10-04T23:21:24.770

59 Simplest way to check if two integers have same sign? 2008-09-15T20:57:04.390

59 What does a bitwise shift (left or right) do and what is it used for? 2011-06-17T12:35:03.910

59 Android In App Billing: securing application public key 2013-01-16T06:47:53.177

58 What USEFUL bitwise operator code tricks should a developer know about? 2009-10-07T17:44:35.093

58 Manipulate alpha bytes of Java/Android color int 2013-03-10T06:37:28.803

57 Fast way to generate pseudo-random bits with a given probability of 0 or 1 for each bit 2016-03-04T11:38:49.000

53 Catch and compute overflow during multiplication of two large integers 2009-11-29T12:14:59.330

53 Efficient way to OR adjacent bits in 64-bit integer 2015-12-08T11:29:40.907

52 Understanding PHP & (ampersand, bitwise and) operator 2009-03-01T18:06:53.207

52 How to add two numbers without using ++ or + or another arithmetic operator 2009-07-19T13:45:57.170

50 Checking if a bit is set or not 2010-03-12T09:45:27.433

50 What does bitwise XOR (exclusive OR) mean? 2011-06-18T19:35:47.547

50 Can XOR of two integers go out of bounds? 2015-02-04T11:39:25.670

49 Two's Complement in Python 2009-10-22T00:53:12.910

49 How does this work? Weird Towers of Hanoi Solution 2010-02-05T19:37:39.483

48 Is there an elegant way to Invert a Bit value in an SQL insert Statement? 2010-07-24T10:44:41.907

48 Arithmetic bit-shift on a signed integer 2010-10-24T19:05:38.847

47 Understanding the bitwise AND Operator 2010-08-06T20:33:56.223

47 Convert 0x1234 to 0x11223344 2014-02-14T04:20:40.567

46 BitSet to and from integer/long 2010-03-18T21:56:01.990

45 Bitfield manipulation in C 2009-06-25T15:40:47.197

45 How do you set, clear and toggle a single bit in JavaScript? 2009-09-17T02:30:59.860

45 How can I perform multiplication without the '*' operator? 2010-01-15T04:20:07.870

45 warning: left shift count >= width of type 2010-11-17T03:48:22.967

45 Implement division with bit-wise operator 2011-03-12T19:29:27.537

45 Java "Bit Shifting" Tutorial? 2011-06-06T09:36:30.153

44 bit-wise operation unary ~ (invert) 2011-09-02T02:44:23.340

44 What is the purpose of "int mask = ~0;"? 2017-09-23T06:19:27.917

43 Checking flag bits java 2011-05-20T04:17:40.893

42 Bitwise operator for simply flipping all bits in an integer? 2011-06-14T23:28:56.817

40 What is the fastest way to return the positions of all set bits in a 64-bit integer? 2013-12-20T22:35:53.817

38 When to use Bitwise Operators during webdevelopment? 2008-11-04T06:21:45.460

38 Speed up bitstring/bit operations in Python? 2010-05-24T13:31:13.300

38 Two elements in array whose xor is maximum 2012-02-16T22:30:47.360

38 Bit count : preprocessor magic vs modern C++ 2017-07-19T11:08:55.907

38 Is "-1>>5;" unspecified behavior in C? 2017-10-16T18:57:58.203

37 Bitwise operations on 32-bit unsigned ints? 2011-07-23T03:51:05.610

37 How Does The Bitwise & (AND) Work In Java? 2013-06-23T00:32:34.130

37 How to find the position of the only-set-bit in a 64-bit value using bit manipulation efficiently? 2015-09-01T19:02:34.173

36 Fastest way to clamp a real (fixed/floating point) value? 2009-01-09T09:13:11.693

35 How does this bitwise operation check for a power of 2? 2009-06-27T20:44:00.153

35 Flags enum & bitwise operations vs. “string of bits” 2009-08-17T02:58:11.030

35 Unsigned Integer in Javascript 2009-12-15T16:07:34.957

35 Find most significant bit (left-most) that is set in a bit array 2010-04-06T23:42:59.157

35 Compute fast log base 2 ceiling 2010-07-17T16:59:05.903

35 n is negative, positive or zero? return 1, 2, or 4 2012-03-04T20:33:39.683

34 Add two integers using only bitwise operators? 2010-11-01T10:16:18.840

33 Is there a way to perform a circular bit shift in C#? 2008-08-29T19:54:43.047

33 Fast divisibility tests (by 2,3,4,5,.., 16)? 2011-08-01T09:32:56.630

33 bitwise XOR of hex numbers in python 2012-06-20T12:32:29.823

33 Why does ((unsigned char)0x80) << 24 get sign extended to 0xFFFFFFFF80000000 (64-bit)? 2015-04-09T12:47:12.443

32 How to compute a 3D Morton number (interleave the bits of 3 ints) 2009-06-21T21:08:25.260

32 How to define and work with an array of bits in C? 2010-03-26T17:26:15.550