Do signed nibbles make any sense?

190 views Asked by At

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?

0

There are 0 answers