bitflags Questions
2
Take a typical check for bit-flags:
if (v & (1 << 0)) != 0 { foo(); }
else if (v & (1 << 1)) != 0 { bar(); }
else if (v & (1 << 2)) != 0 { baz(); }
How would this b...
4
Solved
Consider this class:
public class MyClassOfMystery {
public static final int NO_FLAGS = ~0;
public static final int FIRST_FLAG = 1;
public static final int SECOND_FLAG = 1 << 1;
public ...
1
Solved
I am dealing with file status flags.
Among test I performed, I found
#include <stdio.h>
#include "fcntl.h"
int main() {
const int flag = O_RDONLY;
printf( "*** Flag O_RDONLY = %5d\n", fla...
Galvanism asked 20/5, 2020 at 22:1
6
Solved
1
Solved
I'm a Rust beginner which comes from C/C++. To start off I tried to create a simple "Hello-World" like program for Microsoft Windows using user32.MessageBox where I stumbled upon a proble...
Citrange asked 10/4, 2018 at 15:22
2
Solved
I am trying to decode a bitmask
[Flags]
public enum Amenities
{
BusinessCenter = 1,
FitnessCenter = 2,
HotTub = 4,
InternetAccess = 8,
KidsActivities = 16,
Kitchen = 32,
PetsAllowed = 64,
...
2
Solved
I'm porting some imperative code to Haskell. My goal is to analyze an executable, therefore each byte of the text section gets assigned a number of flags, which would all fit in a byte (6 bits to b...
3
Solved
Currently I'm using enums to represent a state in a little game experiment. I declare them like so:
namespace State {
enum Value {
MoveUp = 1 << 0, // 00001 == 1
MoveDown = 1 << 1, ...
Binkley asked 16/6, 2014 at 20:11
4
Solved
I have a data model with a bitfield defined something like this:
alter table MemberFlags add column title varchar(50) not null default '';
alter table MemberFlags add column value integer( 3) not ...
Wrennie asked 12/8, 2010 at 4:25
2
Suppose, for the sake of this example, that I am trying to parse a file which specifies that two arbitrary bytes in the record represent the day of the week, thusly:
DayOfWeek:
- 0 = Monday
- 1...
8
Solved
I have a byte I'm using for bitflags. I know that one and only one bit in the byte is set at any give time.
Ex: unsigned char b = 0x20; //(00100000) 6th most bit set
I currently use the followin...
Tiros asked 20/1, 2013 at 21:41
3
Solved
While revising some old c++ code, I ran across several bitflags defined as enums.
enum FooFlags
{
FooFlag1 = 1 << 0,
FooFlag2 = 1 << 1,
FooFlag3 = 1 << 2
// etc...
};
This ...
Parcel asked 19/11, 2010 at 16:17
1
Possible Duplicate:
C# int to enum conversion
Is it somehow possible to convert an int to a flag combination enum? So, if
[Flags]
public enum Foo {a = 0x80,
b = 0x40,
c = ...,
......
5
Solved
I like to write enum or integer to pass option to my methods. Is there a pattern or a method in C# to check if an (int 1,2,4,8,...) option is true or false. I think it should easily be possible via...
Disperse asked 20/5, 2011 at 9:21
2
Solved
I made a function to set or clear a specific number of bits in a DWORD. My function works. I don't need help making it work. However, I am wondering if the method I've chosen to do it is the fastes...
Yellowtail asked 25/1, 2011 at 23:58
3
Solved
I've seen some possible approaches (in some database engines some of them are synonyms):
TINYINT(1)
BOOL
BIT(1)
ENUM(0,1)
CHAR(0) NULL
All major database engine supported by PHP should be noted...
Facile asked 26/12, 2010 at 22:41
2
Solved
I am attempting to learn more about this to implement in my project.
I currently have got this basically:
unsigned char flags = 0; //8 bits
flags |= 0x2; //apply random flag
if(flags & 0x2)...
Kesha asked 16/11, 2010 at 6:16
6
Solved
Was looking at how enums can be used as bit flags by decorating them with the flags attribute and bitwize operators (see below).
Are there any places in the .NET framework that this pattern is use...
6
Solved
Edit: It seems most people misunderstood my question.
I know how enum works, and I know binary. I'm wondering why the enums with the [Flags] attribute is designed the way it is.
Original post:
T...
4
Solved
Using enums for storing bitflags in C++ is a bit troublesome, since once the enum values are ORed they loose their enum-type, which causes errors without explicit casting.
The accepted answer for ...
Tsana asked 7/11, 2009 at 16:29
1
© 2022 - 2024 — McMap. All rights reserved.