Skip to main content
Filter by
Sorted by
Tagged with
4 votes
3 answers
179 views

I am trying to figure out a code that would be able to swap the higher half and the lower half of the binary form of an integer number such as for example: 0000000 00110011 01001001 11111110 turn into ...
Fe A person Mo's user avatar
-1 votes
3 answers
97 views

Assume I have a 1 source variable (int) which is 10 bits long. Let's call it src. I have 2 destination variables (int) which are 8 bits long namely byte1 and byte2. MSB LSB src ...
user1175097's user avatar
2 votes
2 answers
223 views

I am trying to solve the problem posed in this question which asks that division of two numbers be performed in a bitwise manner. So, I wrote the following functions. sum() adds two numbers. larger() ...
uran42's user avatar
  • 469
5 votes
1 answer
256 views

I have an array of 64-bit words, which I need to compact by removing the most significant 24 bits of each 64-bit word. Essentially this code in pure C: void repack1(uint8_t* out, uint64_t* in) { ...
swineone's user avatar
  • 3,000
-4 votes
2 answers
105 views

In the hex byte A1 B2 C3 D4, ABCD would be the most significant bits of each pair, and 1234 would be the least significant. I find that these groups of bits are often operated on together in hardware-...
Hashim Aziz's user avatar
  • 6,576
3 votes
1 answer
203 views

I'm working on performance-critical code and experimenting with different ways to extract bit fields from 64-bit integers. I expected that using intrinsics like _bextr_u64 (Bit Field Extract) would be ...
caquis caquis's user avatar
-3 votes
2 answers
127 views

#include <stdio.h> #include <stdlib.h> #include <limits.h> int main(void) { int v; int sign; sign = -(v < 0); printf("%d", sign); } Why ...
Mustafa's user avatar
2 votes
1 answer
254 views

As part of a test I was given, I am required to code the instructions below: A function F(x) is defined over integers x >= 0 as: F(x) = ∑ [(x | i) - (x & i)] (summation ∑ is over i), with i ...
Giogre's user avatar
  • 1,664
-1 votes
1 answer
179 views

this is the problem(counting bits)from cses i have attached the link here https://cses.fi/problemset/task/1146/ the goal of the problem is to calculate the number of set bits in all the number from 1 ...
eternal_011's user avatar
0 votes
1 answer
64 views

Looking into solving a very large data set problem by using bit manipulation to reduce compute Imagine billions of records that look like this(but more than 20k in length): Questions : A,B,C,D ...
HFX's user avatar
  • 31
1 vote
0 answers
63 views

I was trying to understand the BCJ ARM64 filter in xz here, (also the 7zip version for reference) I don't understand the case for the ADRP instruction, this is the snippet for it from xz: else if ((...
Ben Kollar's user avatar
9 votes
3 answers
334 views

This question arose specifically in the context of exploratory work for RISC-V platforms which may optionally support a carry-less multiplication instruction CLMUL. It would equally apply to other ...
njuffa's user avatar
  • 27.1k
1 vote
2 answers
110 views

I'm trying to understand why the following solution for LeetCode's Single Number II works in Python: class Solution: def singleNumber(self, nums: List[int]) -> int: number = 0 ...
Sourav Mandal's user avatar
0 votes
1 answer
168 views

We have a use of subnets for doing geo location of computer assets. In the most up to date data we do not have subnets IE 10.81.66.0, we just have the IP address and subnet mask such as 255.255.255.0 ...
Cyclone's user avatar
  • 13
0 votes
0 answers
68 views

I am sorry, I love C++, and so it is embarrassing that I have to ask: how can I store four uint8_t values in a single uint32_t? Or a uint64_t if necessary. This involves bit-meddling but I lack the ...
fish2000's user avatar
  • 4,435
0 votes
2 answers
151 views

I'm reading The C Programming Language by K & R 2nd edition and got to the bitwise operators. Why, on C, the Complement (~) Operator applied to a N number, returns -(N + 1) ? When it normally just ...
nerdpanda's user avatar
2 votes
1 answer
172 views

I'm currently studying encryption and I was coming up with ways of reversing the nibbles of a byte (ex. 0xF5 => 0x5F). I came up with this solution: byte >> 4 | (byte & 0x0F) << 4 ...
Legended's user avatar
  • 151
3 votes
3 answers
199 views

I have the following 2 bytes to decode: 0000 0000 0111 1011 and I wish to fill this structure struct ctn { uint16_t fx : 1; uint16_t stn: 15; ctn() : fx(0), stn(0) {} } PACKED; I store ...
tj26's user avatar
  • 391
3 votes
1 answer
125 views

My gcc version is 12.4.0. code is below: int x1 = 0x80000000; printf("%d\n\n", x1 ^ (~x1 + 1)); printf("%d\n\n", !(x1 ^ (~x1 + 1))); I though the output should be 0 and 1, since !...
link2332's user avatar
0 votes
1 answer
75 views

I saw an implementation of a bit mask in the following code, but I don't understand how it works. Can someone explain how the expression in the bit mask works? The author's comments are at the top of ...
BreenDeen's user avatar
  • 744
1 vote
1 answer
117 views

when shifting bytes, there are some scenarios that do not seem to make sense, for example printf("shifted bytes %llx\n",(((long long)1 << 63 ))>>1); outputs c000000000000000, ...
user20695956's user avatar
2 votes
1 answer
133 views

I'm working on a 16 byte array or 128 bits fully populated with the following bit fields: struct data { uint ttg : 16; // time to go, units:mins int volts : 16; // units:10mV uint ...
ChrisJ's user avatar
  • 23
0 votes
0 answers
49 views

I'm using a website called dcoder.tech to help me test how well I use swift. They show you one test case and the results that your code should output. You write a program that takes input, the website ...
Justa Guy's user avatar
-1 votes
1 answer
131 views

Here I am tasked with creating an UnsignedBigInteger class that can handle numbers bigger than a long. Am allowed to use a byte array as the internal representation, uint8_t[]. What I came up with is ...
Giogre's user avatar
  • 1,664
2 votes
1 answer
188 views

Problem statement: I am encountering an issue when running the following multi-threaded program. The program spawns a large number of threads (10,000) that process the same byte array value. The issue ...
Amey Sawant's user avatar

1
2 3 4 5
161