bitwise-and Questions

6

Solved

I am trying to do assignment: "Find the number of bits in an unsigned integer data type without using the sizeof() function." And my design is to convert the integer to bits and then to count them...

3

Solved

What does this code mean and what are other ways accomplish the same without using bit shifting? if ($n & ($n - 1))
Lottielotto asked 11/10, 2009 at 19:16

4

Solved

Java has binary-or | and binary-and & operators: int a = 5 | 10; int b = 5 & 10; They do not seem to work in Kotlin: val a = 5 | 10; val b = 5 & 10; How do I use Java's bitwise op...
Vexation asked 27/1, 2018 at 9:45

4

I just started learning about bit wise operation and want to ask why and 1 ( &1) bitwise operation always return 0 or 1 .
Calcariferous asked 6/1, 2017 at 7:38

6

Solved

I am reading some code that implements a simple parser. A function named scan breaks up a line into tokens. scan has a static variable bp that is assigned the line to be tokenized. Following the as...
Seidel asked 24/5, 2021 at 19:5

7

I am trying to extract blue colour of an input image. For that I create a blue HSV colour boundary and threshold HSV image by using the command mask_img = cv2.inRange(hsv, lower_blue, upper_blue) ...
Filmdom asked 25/9, 2015 at 4:44

11

Solved

How do you do the XOR bitwise operation if you only have available the AND and the OR operations?
Remittee asked 17/1, 2011 at 16:8

3

Solved

I got two objects, a and b, each containing a single byte in a bytes object. I am trying to do a bitwise operation on this to get the two most significant bits (big-endian, so to the left). a = s...
Englut asked 23/3, 2014 at 16:47

3

Solved

Given two numbers L & R , Find Bitwise AND of all numbers lying between L and R inclusive Constraints 1<= L,R <= (2^32). LL step = 1; while(L!=R) { L/=2; R/=2; step*=2; } cout<...
Yeta asked 11/8, 2015 at 18:38

8

Solved

Can anyone help what n&-n means?? And what is the significance of it.
Cupulate asked 13/3, 2013 at 20:2

1

Solved

I have been reading about an implementation of the diamond-square algorithm in C# that wraps around to create seamless textures. To calculate the next point, an average is taken of four sample poin...
Fia asked 13/10, 2017 at 8:41

2

Where '-' denotes negative x, and '&' denotes bitwise AND. The numbers are in 8-bit 2's complement in a program and I can't seem to find the correlation between inputs and outputs. 8 & (-...
Cardioid asked 2/10, 2017 at 18:13

1

Solved

Is there any actual difference in performance? Is it faster? (lets say I use it in at least 100 cases in the same program, would it improve my program in terms of speed?)
Arber asked 30/12, 2016 at 20:14

7

Solved

I faced an interesting scenario in which I got different results depending on the right operand type, and I can't really understand the reason for it. Here is the minimal code: #include <iostr...

2

Solved

I look through java source code try to learn the implementation of collection. Found a interesting thing in the ArrayDeque class. public E pollFirst() { int h = head; @SuppressWarnings("unchecke...
Infallible asked 24/4, 2016 at 15:32

4

Solved

My processor can only do arithmetic operations on 8-bit or 16-bit unsigned integers. 1) This means the word size for this processor is 16 bits, correct? Operations on words are O(1). The reaso...
Antares asked 25/4, 2016 at 1:24

3

Solved

For example: int get(int i) { int res = 0; while (i) { res = (res + tree[i]) % MOD; i -= ( (i) & (-i) ); } return res; } A tree update function: void update(int i, int val) { w...
Photoflash asked 8/3, 2016 at 7:14

4

Solved

I have the following Java code: byte value = 0xfe; // corresponds to -2 (signed) and 254 (unsigned) int result = value & 0xff; The result is 254 when printed, but I have no idea how this cod...
Phyfe asked 8/7, 2012 at 1:47

7

Solved

I've been looking at posts about masks, but I still can't get my head around how to extract certain bits from a number in C. Say if we have an integer number, 0001 1010 0100 1011, its hexadecimal r...
Fabliau asked 14/10, 2014 at 10:54

8

Solved

How do you perform a bitwise AND operation on two 32-bit integers in C#? Related: Most common C# bitwise operations.
Andante asked 18/12, 2009 at 16:39

1

Solved

I've the given condition from a cpp source. if (!(faces & activeFace) || [...]) { ... } I want to translate this into C#. When I understand this right, this means as much as if activeFace i...
Lynden asked 4/8, 2014 at 19:40

3

Solved

I am working on BitWise AND operator in javascript. I have two 32 bit nunber 4294901760 (11111111 11111111 00000000 00000000) and 4294967040 (11111111 11111111 11111111 00000000) when I and t...
Hypertonic asked 4/4, 2013 at 7:26

1

From what I understand the & operator is similar to the && operator except that the && only checks the second if the first is true, while the & checks both regardless of the...
Pasteboard asked 17/12, 2013 at 23:19

3

Solved

Doesn't bitwise-ANDing with 0xff essentially mean getting the same value back, for that matter, in this code? byte[] packet = reader.readPacket(); short sh; sh = packet[1]; sh &= 0xFF; System....
Aggrieved asked 27/9, 2013 at 23:23

4

Solved

I just read this code following: byte[] bts = {8, 0, 0, 0}; if ((bts[i] & 0x01) == 0x01) Does this do the same thing as if (bts[i] == 0x01) If not,what's the difference between them? A...
Rockery asked 31/7, 2013 at 10:54

© 2022 - 2024 — McMap. All rights reserved.