Adding 2 hex values 
Author Message
 Adding 2 hex values

Hello,
in an external viewer I can easily add 2 hex values by selecting both,
and I was astonished by the result.

For example I select

"Hex:20" and "Hex:03"
(which would be "Hex:20,Dec:32" and "Hex:03,Dec:3")

The result is "800" in the external viewer, and it's the result I needed.
It concenates the two hex values this way: "03" & "20", then calcuates
the long value from "0320".

Why?
I mean, I thought that it would be "20" & "03", but obviously this isn't
the case.

Can somebody tell me why this has to be done in reverse order?



Thu, 09 Dec 2010 18:21:59 GMT  
 Adding 2 hex values
Look for terms BigEndian and littleEndian.
e.g:
http://en.wikipedia.org/wiki/Big_Endian


Quote:
> Hello,
> in an external viewer I can easily add 2 hex values by selecting both, and
> I was astonished by the result.

> For example I select

> "Hex:20" and "Hex:03"
> (which would be "Hex:20,Dec:32" and "Hex:03,Dec:3")

> The result is "800" in the external viewer, and it's the result I needed.
> It concenates the two hex values this way: "03" & "20", then calcuates the
> long value from "0320".

> Why?
> I mean, I thought that it would be "20" & "03", but obviously this isn't
> the case.

> Can somebody tell me why this has to be done in reverse order?



Thu, 09 Dec 2010 18:28:48 GMT  
 Adding 2 hex values

Quote:

> Look for terms BigEndian and littleEndian.
> e.g:
> http://en.wikipedia.org/wiki/Big_Endian

Too lazy to do so... I'll just take it as "god-given".


Thu, 09 Dec 2010 19:46:47 GMT  
 Adding 2 hex values

Quote:
> > Look for terms BigEndian and littleEndian.
> > e.g:
> > http://en.wikipedia.org/wiki/Big_Endian

> Too lazy to do so... I'll just take it as "god-given".

  Don't let me get you up from the TV, but for the
sake of anyone else who might be curious enough
to struggle through reading a few more sentences:

  On Windows numbers are generally stored in
"reverse" when binary data represents numeric
values. (As opposed to the "Motorola" storage
pattern used on Macs.) The first byte is the
lowest. So in a stored integer, the left byte is
(bytevalue x 1). The second byte is (bytevalue x 256).
20 03 is (32 x 1) + (3 x 256).



Thu, 09 Dec 2010 22:11:18 GMT  
 Adding 2 hex values
I rarely set in front of the PC! "Lazy" was meant in a pragmatical way.


Fri, 10 Dec 2010 07:29:04 GMT  
 Adding 2 hex values

Quote:
> I rarely set in front of the PC! "Lazy" was meant in a pragmatical way.

What,,,

Sub a()
Debug.Print Val(&H20) + Val(&H3) ' 35
Debug.Print Val(&H20) & Val(&H3) ' 323
Debug.Print "20" + "03" ' 2003
Debug.Print "20" & "03" ' 2003
End Sub

What ???



Sat, 11 Dec 2010 01:16:03 GMT  
 Adding 2 hex values

Quote:

>> I rarely set in front of the PC! "Lazy" was meant in a pragmatical way.

> What,,,

> Sub a()
> Debug.Print Val(&H20) + Val(&H3) ' 35
> Debug.Print Val(&H20) & Val(&H3) ' 323
> Debug.Print "20" + "03" ' 2003
> Debug.Print "20" & "03" ' 2003
> End Sub

> What ???

Bert was talking about an external hex viewer. On screen the numbers
probably appeared like this:

20 03

but when he highlighted those numbers the application displayed the value as
being 800 (dec), which is not what you'd expect from the hex number &H2003,
but it IS what you would expect from &H0320. Get it now?



Sat, 11 Dec 2010 01:53:03 GMT  
 Adding 2 hex values

Quote:



> >> I rarely set in front of the PC! "Lazy" was meant in a pragmatical way.

> > What,,,

> > Sub a()
> > Debug.Print Val(&H20) + Val(&H3) ' 35
> > Debug.Print Val(&H20) & Val(&H3) ' 323
> > Debug.Print "20" + "03" ' 2003
> > Debug.Print "20" & "03" ' 2003
> > End Sub

> > What ???

> Bert was talking about an external hex viewer. On screen the numbers
> probably appeared like this:

> 20 03

> but when he highlighted those numbers the application displayed the value as
> being 800 (dec), which is not what you'd expect from the hex number &H2003,
> but it IS what you would expect from &H0320. Get it now?

OK 320, got it...

Thanks



Sat, 11 Dec 2010 01:57:03 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Converting hex value in str format to hex

2. Finding the number value of a hex value

3. unescape (or convert) to hex value Attachments

4. Hex values in VB...

5. Allowing only Hex values...

6. RegWrite with long hex values

7. RGB with hex values fails on Windows2000

8. Help me convert system color NAMES to hex or RGB VALUES

9. Hex to ASCII values?

10. Bits and hex values

11. HEX values for colors in VB

12. Registry Hex Values

 

 
Powered by phpBB® Forum Software