Results 1 to 3 of 3

Thread: Byte to Nibble, Nibble to Byte

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    99

    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.

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    99

    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
  •  



Click Here to Expand Forum to Full Width