bitwise-operators Questions

9

Solved

Apple sometimes uses the Bitwise-Shift operator in their enum definitions. For example, in the CGDirectDisplay.h file which is part of Core Graphics: enum { kCGDisplayBeginConfigurationFlag = (1 ...
Collation asked 22/10, 2010 at 18:44

3

Solved

I know of base classes Enum and IntEnum. Both are very helpful but I miss features for flag operations. I don't expect that these two classes implement my wished feature. Let's construct an example...
Deception asked 24/4, 2016 at 22:53

3

Solved

I am trying to solve a problem, using python code, which requires me to add two integers without the use of '+' or '-' operators. I have the following code which works perfectly for two positive nu...
Chickie asked 24/8, 2016 at 2:27

4

The problem for signed 2's complement 32-bit integers: satMul2 - multiplies by 2, saturating to Tmin or Tmax if overflow. Examples: satMul2(0x30000000) = 0x60000000            satMul2(0x40000000) ...

1

My situation is the same as in this question, but instead of using floats, I'm using integers. I feel like this difference might be significant because there might be some bit twiddling hacks that ...

7

Solved

What is the equivalent (in C#) of Java's >>> operator? (Just to clarify, I'm not referring to the >> and << operators.)
Harkins asked 10/12, 2009 at 10:50

7

Given the 32 bits that represent an IEEE 754 floating-point number, how can the number be converted to an integer, using integer or bit operations on the representation (rather than using a machine...
Siphonophore asked 9/9, 2012 at 20:57

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

10

Solved

My code looks like this: TextView task_text = (TextView) view.findViewById(R.id.task_text); task_text.setPaintFlags( task_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); This causes a str...
Uranic asked 22/7, 2011 at 22:36

3

I have a 32-bit value in the lower part of a 64-bit register; the top part is 0's. Letting X denote a bit with information and with bits listed from LSB to MSB, here's what it looks like: X X X ......
Hominy asked 7/12, 2017 at 10:28

5

How can one use in SQL Server the processing of the Flags such as on enums in C#? For example, how would one return a list of users that are part of a list or conditions like so: ConditionAlpha...
Sandal asked 30/11, 2012 at 12:33

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

3

Solved

bool check(const char *text) { char c; while (c = *text++) { if ((c & 0x80) && ((*text) & 0x80)) { return true; } } return false; } What's 0x80 and the what does the whole m...
Descant asked 25/1, 2022 at 23:36

4

Solved

I wanna do some bitwise operations (for example xor two files) on files in Linux , and I have no idea how I can do that. Is there any command for that or not? any help will be appreciated.
Bitterling asked 31/7, 2011 at 11:6

5

This is a homework assignment which requires me to come up with a function to determine if x < y, if it is I must return 1, using only bitwise operators ( ! ~ & ^ | + << >> ). I ...
Fugate asked 29/1, 2013 at 17:1

3

Solved

I want to get the index which equals to 1 in binary format, now I use codes like this: inline static uint8_t the_index(uint32_t val){ return uint8_t(log(val & ((~val) + 1))/log(2)); } I want ...
Pedaias asked 29/11, 2021 at 9:29

6

Solved

Assume that I have: unsigned int x = 883621; which in binary is : 00000000000011010111101110100101 I need the fastest way to swap the two lowest bits: 00000000000011010111101110100110 Note: To c...
Cinema asked 28/10, 2021 at 10:36

7

Solved

I am facing a rather peculiar problem. I am working on a compiler for an architecture that doesn't support bitwise operations. However, it handles signed 16-bit integer arithmetics and I was wonder...

4

Solved

Context: I'm learning C# and have been messing about on the Pex for fun site. The site challenges you to re-implement a secret algorithm, by typing code into the site and examining how the inputs ...
Zacynthus asked 10/7, 2014 at 17:46

2

Solved

What would be the best way to apply the bitwise OR operator (or any operator I suppose) to an array of values in javascript? var array = [1, 5, 18, 4]; // evaluate 1 | 5 | 18 | 4
Scissure asked 30/10, 2015 at 13:49

1

Solved

I'm a beginner to programming in general so i'm sorry if i make some mistakes while putting this question up. The tutorial I'm following goes over this code: package main import ( "fmt"...
Earthworm asked 29/7, 2021 at 12:16

10

I occasionally will come across an integer type (e.g. POSIX signed integer type off_t) where it would be helpful to have a macro for its minimum and maximum values, but I don't know how to make one...
Polypody asked 22/12, 2010 at 23:12

7

How can I implement bitwise operators in Lua language? Specifically, I need a XOR operator/method.
Deferral asked 12/5, 2011 at 12:2

15

Solved

I always thought that && operator in Java is used for verifying whether both its boolean operands are true, and the & operator is used to do Bit-wise operations on two integer types. R...
Epidermis asked 6/4, 2011 at 9:46

27

Solved

How can I set, clear, and toggle a bit?
Changeless asked 7/9, 2008 at 0:42

© 2022 - 2025 — McMap. All rights reserved.