bitwise-operators Questions

1

I am working with an assembly language that does not contain either multiply, divide, or bit-shift instructions. I am aware that a left bit-shift can be achieved by just adding the same number to i...

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...

9

Solved

What is the C# equivalent (.NET 2.0) of _rotl and _rotr from C++?
Fimbriation asked 1/5, 2009 at 16:6

9

Solved

I've come up with several manual ways of doing this, but i keep wondering if there is something built-in .NET that does this. Basically, i want to reverse the bit order in a byte, so that the leas...
Kristinkristina asked 27/8, 2010 at 20:17

7

Solved

How can I overload the |= operator on a strongly typed (scoped) enum (in C++11, GCC)? I want to test, set and clear bits on strongly typed enums. Why strongly typed? Because my books say it is goo...

3

Solved

I was working on an algorithm of sub sequences. What is the meaning of the statement: if (counter & (1<<j)) within the context of the program below: void printSubsequences(int arr[], int...

2

Solved

How to write in Kotlin: flags |= newFlag Only what I have found is: flags = flags or newFlag Is there a build-in bitwise or operator with assignment?
Borsch asked 13/5, 2014 at 15:5

4

Solved

I've been reading the classic Hacker's delight and I am having trouble understanding the difference between logical shift right,arithmetic shift right, and rotate right. Please excuse if the doubt ...
Portia asked 22/6, 2017 at 9:6

8

Solved

I see a "pipe" character (|) used in a function call: res = c1.create(go, come, swim, "", startTime, endTime, "OK", ax|bx) What is the meaning of the pipe in ax|bx?
Aalborg asked 13/5, 2011 at 7:29

18

Solved

int a = 12; for eg: binary of 12 is 1100 so answer should be 3 as 3rd bit from right is set. I want the position of the last most set bit of a. Can anyone tell me how can I do so. NOTE : I want...
Edric asked 13/7, 2015 at 20:44

4

Solved

I have an assignment that asks to do a number of functions only using these operators: ! ~ & ^ | + << >> In some of the problems it is useful to make some integer, x, become all 1s if i...
Moersch asked 1/2, 2013 at 22:41

5

Solved

I'm new to js and I wonder if there is a XNOR operator in JS. I tried !(a^b) but it gives weird result. For example: var a,b="aa"; a^b this code returns true, however, I XNOR returns false. UPD...
Bicapsular asked 7/6, 2018 at 13:25

4

Solved

This is more of a just for fun question. I’m working on a SC61860 CPU, which is an 8-bit CPU for a Sharp PC-1360 Pocket Computer from 1987 (also used in PC-1401 & 1403’s). Its instruction set d...

5

Solved

I worte these methods in Objective-C. They're just checksum and XOR some NSData - (void)XOR:(NSMutableData *)inputData withKey:(NSData *)key { unsigned char* inputByteData = (unsigned char*)[inpu...
Cockpit asked 1/4, 2015 at 4:33

2

When I use the following minimal code in an C++ console application in Visual Studio 2019, I get two warnings, which are completely opposite. int main() { unsigned char op1 = 0x1; unsigned char o...
Defendant asked 25/8, 2023 at 10:7

19

Solved

Why is it that ~2 is equal to -3? How does ~ operator work?
Chassis asked 26/4, 2009 at 18:29

11

Solved

Let's say I have an integer called 'score', that looks like this: int score = 1529587; Now what I want to do is get each digit 1, 5, 2, 9, 5, 8, 7 from the score using bitwise operators(See belo...
Llamas asked 25/6, 2010 at 13:44

6

I am fairly new to C programming, and I encountered bit masking. What is the general concept and function of bit masking? Examples are much appreciated.

5

What is the difference between & and && in C? My teacher gave me this example: int a = 8; int b = 4; printf("a & b = %d\n", a & b); printf("a && b = %d\n", a &&amp...
Brewer asked 2/4, 2018 at 19:1

11

Solved

I'm trying to convert an integer to binary using the bin() function in Python. However, it always removes the leading zeros, which I actually need, such that the result is always 8-bit: Example: ...
Collaborative asked 4/6, 2013 at 19:41

6

I saw a some solutions but its look complex. What are the most effective way to swap between two bits in n,m postions? int swapBits(int num, int nPostion, int mPosition);
Neurath asked 21/7, 2016 at 10:16

3

Solved

I'm trying to write a shader that uses many bit operations. In fact they are supported since glsl 1.30, but I'm only on OpenGL 2.1. Is there any way to use bit operations with my OpenGL version?
Cumin asked 9/7, 2011 at 11:45

10

Could someone please explain to me the usage of << and >> in Go? I guess it is similar to some other languages.
Herschel asked 27/4, 2011 at 7:54

4

Solved

I've written a function trailing_zeroes(int n) that returns the number of the trailing zeroes in the binary representation of a number. Example: 4 in binary is 100, so the function in this case ret...
Castellany asked 20/7, 2017 at 17:52

12

Solved

How do I check if an integer is even or odd using bitwise operators
Billow asked 18/4, 2011 at 9:29

© 2022 - 2024 — McMap. All rights reserved.