3,616 questions
2
votes
2
answers
158
views
Simple C malloc question that prints garbage on multiple invocations [closed]
I'm refreshing my C skills (been decades) and ran across something I don't quite understand. I'm working on some code that involves a lot of bit shifting, masking, etc. I have one function that ...
Advice
0
votes
1
replies
42
views
Back to the bit test question in JavaScript
Given:
all numbers are valid BigInts for expanding to 128 bits and beyond
buttonArray holds 64 button objects
a button is initalized through a .forEach loop and pushed onto buttonArray
this makes ...
-4
votes
2
answers
125
views
Is there a name for the high and low bits of a hex string?
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-...
0
votes
1
answer
99
views
DB2 LUW What's up with BINARY vs. CHAR FOR BIT DATA column data types?
We have DB2 LUW v11.5 and it supports both BINARY and CHAR FOR BIT DATA column data types. I've read the documentation, and I've Googled it, but I don't really see an effective difference between ...
0
votes
0
answers
85
views
Which of these two bitwise expressions is faster, and is there an optimized alternative?
I have two bitwise expressions and need to figure out which one is faster. Also, if there are other ways to implement the same, but in a faster way than the given expression. I am using these ...
-3
votes
1
answer
73
views
I can't find the error in this code. It is x86 assembly
Input: unsigned char vet[] = { 0xBC,0xFF,0x01 };unsigned short int len = 18;
Output: short int minLung;short int maxLung;
Given a sequence of bits, determine the minimum and maximum length of ...
0
votes
1
answer
70
views
bit manipulation for big data processing with complex boolean logic
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
...
1
vote
1
answer
83
views
Grouping bits based on binary mask [duplicate]
I am looking for an algorithm to group bits from byte A based on mask (or tap) from B, on byte C, starting from least-significant. By way of example, the mask/tap (B) has bits 1,3,4 set to 1, which ...
1
vote
3
answers
147
views
Powershell converting bit values to Boolean in result set
I have an issue whereby a query called via Invoke-SQLCmd returns a certain set of results. For some columns the value is a 0 or 1 of BIT data type. The results instead come back as False or True in ...
0
votes
1
answer
99
views
How much data uses an especific function [closed]
How can I determine the exact amount of memory in megabytes that a "char" data type uses, beyond just knowing its size in bytes, nibbles, kilobytes, and bits?
I’ve tried using sizeof and ...
1
vote
0
answers
73
views
question at / pivot and >> 2 in C++ Solution for Next Higher Number
I came across the following C++ solution for finding the smallest number greater than n that has the same number of 1's in its binary representation
int solution(int n) {
int pivot = n & -n;
...
-2
votes
1
answer
262
views
typescript number type with bit operations [duplicate]
in typescript, as the number type can be int or float, so what if I use number type with bit operations
I have see some library use this
const a = 1.23
const b = a | 0
Sorry for the inaccurate ...
0
votes
1
answer
77
views
How does bitshifting 0xFF to the end of an Uint32 form a complete hexadecimal code?
I've been following along to Cave of Programming's C++ for Complete Beginners on Udemy, and in lesson 67 he goes over bitshifting to output certain colour pixels in an SDL window. There's a certain ...
0
votes
1
answer
145
views
A single byte that is from 0 to 255 to be rescaled from 0 to 7
A single 1 byte could be from 0 to 255. I intend to rescale it to be from 0 to 7. I have done this:
bit8 := uint8(136)
// To re-scale 1 byte from 0 to 2^3-1 i.e. 0 to 7
bit3 := bit8 / 0xff * 0b0111
...
-1
votes
1
answer
135
views
Do Left Shift and Right Shift have better performance compared to multiply and divide operations?
If I want to do the fastest way to calculate x * 2, which one should I use?
x << 1
or
x * 2
With the same logical thinking, if I want to do the fastest way to calculate x / 2, which one should ...