bitmask Questions
6
Solved
Something like
SELECT COUNT(*) AS c FROM BANS WHERE typeid=6 AND (SELECT ipaddr,cidr FROM BANS) MATCH AGAINST 'this_ip';
So you don't first fetch all records from DB and then match them one-by...
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.
Wolfort asked 8/5, 2012 at 6:7
10
Solved
I have a very large set of permissions in my application that I represent with a Flags enumeration. It is quickly approaching the practical upper bound of the long data type. And I am forced to com...
Unclad asked 29/6, 2009 at 21:50
4
Solved
I'm not sure if bitmask is the correct term. Let me explain:
In php, the error_reporting function can be called multiple ways:
// Report simple running errors
error_reporting(E_ERROR | E_WARNING ...
3
Solved
I am working with a table in a PostgreSQL database that has several boolean columns that determine some state (e.g. published, visible, etc.). I want to make a single status column that will store ...
Silicate asked 3/4, 2012 at 10:32
4
Solved
Say for example I have a uint8_t that can be of any value, and I only want to flip all the bits from the least significant bit up to the most significant last 1 bit value? How would I do that in th...
Undertook asked 26/4, 2022 at 5:24
2
I have some integer value representing a bitmask, for example 154 = 0b10011010, and I want to construct a corresponding signal Vector<T> instance <0, -1, 0, -1, -1, 0, 0, -1> (note the ...
Encyclical asked 21/12, 2021 at 13:16
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
4
Solved
Say I have a byte like this 1010XXXX where the X values could be anything. I want to set the lower four bits to a specific pattern, say 1100, while leaving the upper four bits unaffected. How would...
2
Solved
How to calculate number of unordered pairs in an array whose bitwise AND is a power of 2. For ex if the array is [10,7,2,8,3]. The answer is 6.
Explanation(0-based index):
a[0]&a[1] = 2
a[0...
Mancunian asked 31/5, 2020 at 13:52
5
Solved
In python, I have been given a 64 bit integer. This Integer was created by taking several different 8 bit integers and mashing them together into one giant 64 bit integer. It is my job to separate ...
2
Solved
I'm working on a codebase with several bit flags enums which look something like this
public enum BitMask
{
None = 0,
OptionA = 1 << 0,
OptionB = 1 << 1,
OptionAandB = OptionA | ...
Gazzo asked 9/12, 2019 at 11:4
7
Solved
I have this code in a section of my project:
enum myEnum
{
invalid = -1,
val1 = 1,
val2 = 2,
val3 = 4
};
int bitmask = val1 | val3;
if(bitmask & val1)
...
if(bitmask & val2)
...
if...
Goliath asked 7/7, 2011 at 8:11
6
I would like to create a macro or function1 mask(n) which given a number n returns an unsigned integer with its n least significant bits set. Although this seems like it should be a basic primitive...
Tsushima asked 29/9, 2018 at 23:46
6
Solved
Let's say I have the following
int susan = 2; //0010
int bob = 4; //0100
int karen = 8; //1000
and I pass 10 (8 + 2) as a parameter to a method and I want to decode this to mean susan and karen
...
2
I've had some experience in C before, however I have never seen the bitfields feature before. I know one can use bitmasks to isolate certain bits in a data structure, but why then bother with bitfi...
Foreandafter asked 9/7, 2019 at 17:22
2
Solved
I am trying to get an unsigned that will completely be filled with ones (it will be 32 ones in binary representation. I tried to use this:
constexpr unsigned all_ones = (((1 << 31) - 1) <...
Hallvard asked 25/6, 2019 at 18:56
6
How does this function work?
A mask with the least significant n bits set to 1.
Example:
n = 6 --> 0x2F, n = 17 --> 0x1FFFF // I don't get these at all, especially how n = 6 --> 0x2F
Also,...
Mean asked 14/9, 2012 at 0:29
4
Solved
You know in Cocoa there is this thing, for example you can create a UIView and do:
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
I have a custom UIV...
Tannenberg asked 23/4, 2013 at 10:22
9
Solved
To define a category bit mask enum in Objective-C I used to type:
typedef NS_OPTIONS(NSUInteger, CollisionCategory)
{
CollisionCategoryPlayerSpaceship = 0,
CollisionCategoryEnemySpaceship = 1 &l...
Jylland asked 5/6, 2014 at 20:30
6
Solved
You're probably familiar with the enum bitmask scheme, like:
enum Flags {
FLAG1 = 0x1,
FLAG2 = 0x2,
FLAG3 = 0x4,
FLAG4 = 0x8,
NO_FLAGS = 0,
ALL_FLAGS = FLAG1 | FLAG2 | FLAG3 | FLAG4
};
f(F...
2
Solved
In Vulkan you specify the VkPipelineShaderStageCreateInfo's to the VkGraphicsPipelineCreateInfo structure, and presumably there is supposed to be one VkPipelineShaderStageCreateInfo for each shader...
Leary asked 5/8, 2018 at 10:35
2
Solved
Unity's Raycast functions has a parameter you could use to raycast to a particular GameObject. You can also use that parameter to ignore particular GameObject.
For exmple the Raycast function:
pu...
Mote asked 22/4, 2017 at 13:20
3
Solved
I don't quite understand this whole bitmask concept.
Let's say I have a mask:
var bitMask = 8 | 524288;
I undestand that this is how I would combine 8 and 524288, and get 524296.
BUT, how do I...
Bareback asked 23/1, 2013 at 12:40
2
Solved
Is something like the following code possible within a shell script?
var1=0xA (0b1010)
if ( (var1 & 0x3) == 0x2 ){
...perform action...
}
Just to make my intentions 100% clear my desired a...
Brewhouse asked 26/4, 2018 at 19:11
1 Next >
© 2022 - 2025 — McMap. All rights reserved.