Concatenating Bytes?

I have two integers below and their binary string equivalent.
The 2 is the comes first.
These two numbers combined are to somehow total 670 but I can't seem to get how.
Maybe it's a concatenated Bit String or something like that. Because these two integers are consecutive in some binary data I have generated I am trying to produced their decimal equivalent. I can produced it in Hex but not decimal.

Basically I'm asking how the 2 and 914 can be combined to produce 670.

1
2
3
4
5
6
670 - 10 1001 1110



2  -      0000 0010
914 - 1001 0001 0100

914 in binary is 1110010010

Also the only way I can think of to get 670 from anything to do with 914 is by xor'ing it with 268

1110010010
^
0100001100
--------------
1010011110
Last edited on
The examples are rather inconsistent.
Binary 10 1001 1110 = hex 29E = decimal 670
binary 0000 0010 = hex 02 = decimal 2
binary 1001 0001 0100 = hex 914 = decimal 2324

Of course you can get 914 if you treat the last one differently, as a set of three decimal digits encoded in 4 bits each.

Is this a problem from a textbook, or are you attempting to decode a file, or what exactly?



Thanks for looking into that Smac89, it's rather remarkable that you worked that out.

Chervil, Thanks, I think you have touched on something. This example belongs to a PDF stream that has been decompressed though only provides binary output from the stream. It directly translates into HEX and this is where I get the 670 from. Yes, 29E.

If I treat each nibble (4bits) as a separate integer I might get a string of numbers which will represent 670. I'm going to give that a go.
I think I've figured it out.. With your help of course


0010 1001 1110 = 670 = 29E

Breaking this into 4 byte lots.

0000 = 0
0010 = 2
1001 = 9
1110 = 14 = E .

thus..0000 0010 1001 1110 = 029E = 670.

So if this directly translates into hex by using each nibble, then

02 and 9 and 14 (is really 02 and 914). And because you can't represent 91 in a nibble, then 914 must be 9 and 14.

The binary output has to be arranged like this.

1 byte 2 bytes 1 byte. Therefore the 2 bytes represents a binary string of nibbles (4 bytes) and thus, has to be read as such.

I just can't think why they would choose to represent the data this way.
Last edited on
Topic archived. No new replies allowed.