53 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
2
votes
1
answer
177
views
Optimization and Methods for Reversing Nibbles of a Byte
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
...
0
votes
1
answer
213
views
Cast variable to nibble in struct
I face the following. I have a struct like this:
typedef struct
{
uint8 nibble_1 : 4;
uint8 nibble_2 : 4;
uint8 data_1;
uint8 data_2;
uint8 data_3;
} NibbleStruct;
Background ...
0
votes
2
answers
778
views
Convert a 4 bit binary nibble as a string into its hex equivalent value as a string
I'm not sure what I'm doing wrong, but my print statement doesn't seem to be working.
def nib(string):
if string == '0000':
return '0'
if string == '0001':
return '1'
...
0
votes
0
answers
52
views
What would be faster: Spliting a 64-bit word into 16 nibbles and entering them in S-Boxes or using an entire 64-bit word directly as an entry?
This question is related to cryptography, but I believe I'm asking in right place (not in Crypto Stackexchange).
Kuznyechik block cipher splits a 64-bit word into 16 nibbles (4-bits) and use them as ...
1
vote
1
answer
2k
views
Change values in a variable based on a conditional value in R
I want to change values in my username variable but only when they meet a condition set from the variable chatforum. For example, I want all instances of users called "Alex" from Canadian ...
0
votes
3
answers
1k
views
Custom 4 bit data type in C#
I want to create a custom data type which is 4 bits (nibble).
One option is this -
byte source = 0xAD;
var hiNybble = (source & 0xF0) >> 4; //Left hand nybble = A
var loNyblle = (source &...
-2
votes
2
answers
2k
views
How to read only half a byte from a binary file at a time in C?
Looking at the documentation for fread() in C:
Declaration
Following is the declaration for fread() function.
size_t fread(void*ptr, size_t size, size_t nmemb, FILE *stream)
Parameters
ptr − This is ...
6
votes
3
answers
6k
views
Why are binary numbers almost always grouped in 4 bits?
I'm learning ARM so going back to basics with binary/hex arithmetic and it got me thinking about how binary numbers are usually presented in groups of 4, e.g.
1111 1110 1101 1100
Is there a particular ...
1
vote
0
answers
230
views
Do signed nibbles make any sense?
I wrote this helper method to unpack a byte onto nibbles:
public static void Deconstruct(this byte value, out byte nibble1, out byte nibble2)
{
nibble1 = (byte) ((value >> 00) & 0x0F);
...
0
votes
1
answer
181
views
Can C cope with sub-byte instruction addressing?
For example if an architecture supports nibble length instructions but data is byte aligned, will:
void *PointerToAnything;
work? In other words, can the compiler handle this?
1
vote
1
answer
2k
views
Trying to split byte in a byte array into two nibbles
I am given a byte array and i am trying to test if the first 4 bits of the first byte is equal to 4. If not return the error code 2.
I have tried pulling out the byte from the array and splitting ...
0
votes
0
answers
431
views
Properly bit packing for enum and typedef struct
I am trying to do some bit packing to transmit data in the small format possible, but I am unsure how to archive it, I started with a typedef struct where I gave the size to each element, but when I ...
0
votes
1
answer
459
views
Merge 2 integers into 1 byte
I have been working in this since yesterday and I can't seem to fully understand the bit shifting. What I'm trying to accomplish is that, I need to merge 2 numbers into 1 byte. The first number in the ...
0
votes
1
answer
851
views
Bytes to Nibbles to Words to Bytes in C#
I have a 3 byte Array which I need to
Convert each byte to Nibbles
Add Byte_0.Nibble_0 + Byte_0.Nibble_1 + Byte_1.Nibble_2 as WORD
Add Byte_1.Nibble_0 + Byte_2.Nibble_1 + Byte_2.Nibble_2 as WORD
...
1
vote
1
answer
551
views
How to perform binary operations on a nibble/tetrad in php?
So, I have numeric values from 0 to 15, so I saved them in hex codes (0 to f). Now I have a string of data containing hex code values of my nibbles.
Data looks like this:
...