aybe
aybe

Reputation: 16662

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);
    nibble2 = (byte) ((value >> 04) & 0x0F);
}

Then naturally, I thought doing the same for sbyte (signed byte):

public static void Deconstruct(this sbyte value, out byte nibble1, out byte nibble2)
{
    nibble1 = (byte) ((value >> 00) & 0x0F);
    nibble2 = (byte) ((value >> 04) & 0x0F);
}

But well, sbyte is a bit confusing to say the least.

Question:

When unpacking a sbyte (signed byte) as nibbles, should these nibbles also be signed or not?

Upvotes: 1

Views: 213

Answers (0)

Related Questions