|
-
Jan 5th, 2012, 08:15 PM
#1
Thread Starter
Lively Member
Byte to Nibble, Nibble to Byte
Saw this: http://www.vbforums.com/showthread.p...ht=byte+nibble but...
I really am looking to store two nibbles in a byte and that's not what the text is. I have a character set that uses 0-9, . and ; I need only these plus I'll add an end of data value in case I have a byte whose lhs is a real value but whose rhs is null.
Ideally, the compressed and uncompressed targets are both byte arrays.
Thanks.
-
Jan 7th, 2012, 03:34 AM
#2
Re: Byte to Nibble, Nibble to Byte
You'd probably get better responses outside of the maths board, since this question is only tangentially maths-related. Multiplying by 2^4 = 16 will left shift a binary number 4 places, eg. (101) * 16 = (1010000) where parens indicate base 2. Given the two nibbles (1101) and (0011), you can combine them into the byte (11010011) since
(1101) * 16 + (0011) = (11010011)
That's all the math there is. Whether or not there are implementation details that would prevent you from using something as simple as the formula implied by the example above is not clear.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Jan 7th, 2012, 01:31 PM
#3
Thread Starter
Lively Member
Re: Byte to Nibble, Nibble to Byte
Ooops. Didn't notice I was on the math board. Must have been searching/browsing and wound up here (you'd think I'd have learned by now that you really can be too heads down). You have provided a good starting place. I'm throwing your suggestion into the mix with a couple other things I'm looking at. Thanks for the effort and I will repost or redirect to the general forum.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|