"Sunit Joshi" <sj****@ingr.com> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl...
Thanks I had realized that the "if" step was unnecessary. Regarding the
endian, how can I tell if the hex no is in Big/Little endian formats ?
If say cts=500, mts=0x01F4000000000000 is in BigEndian format, then
would I have to use a BigEndianClass.GetBytes(mts) and then use the
Int64 of BitConverter to get the value ? I'm also still interested in
how to compare cts and mts.
Ok, 500 (dec) == 0x0000000001F4.
On a little endian machine, that will be stored as:
F4 01 00 00 00 00 00 00
On a big endian machine, that will be stored as:
00 00 00 00 00 00 01 F4
On a 16-bit, big endian machine, which isn't quite sure what it want to do
with numbers bigger than 16 bit, may store it as:
01 F4 00 00 00 00 00 00
On the other hand, 0x01F4000000000000 == 140,737,488,355,328,000 (dec).
So, when you say that "mts=0x01F4000000000000" it's not quite clear if you
mean that it's "01 F4 00 00 00 00 00 00" in memory (as seen in a hex dump
of the DB record), or that it's actually equal to 140 quadrillion (as seen
by printing out the final value of mts).
There is no BigEndianClass. BitConverter just copies the bytes into an
array. Once they are there you can rearrange them as you see fit.