From: Ara.T.Howard@... Date: 2005-04-26T08:04:31+09:00 Subject: Re: long conversion ... On Tue, 26 Apr 2005, Zach Dennis wrote: > I am reading in more binary data. This time I get 4 bytes with the > following ASCII character values: > > 63 > 2 > 250 > 240 > > I believe this is a set of 4 bytes that correspond to a unsigned long. > The input number is 50. Can anyone make sense of this, or am I way off > here. Thanks, hi zach- so you wan't a word that look like this: harp:~ > irb irb(main):001:0> printf "%32.32b\n", 50 00000000000000000000000000110010 => nil but you have these four bytes: irb(main):002:0> printf "%8.8b\n", 63 00111111 => nil irb(main):003:0> printf "%8.8b\n", 2 00000010 => nil irb(main):004:0> printf "%8.8b\n", 250 11111010 => nil irb(main):005:0> printf "%8.8b\n", 240 11110000 => nil so, not matter what order you put them in, you aren't going to get the bits for 50 out of 'em i'm afraid ;-( in fact, since you know 50 fits into one byte four bytes of a 'long' 50 will have to have three zero filled bytes for most archs. how is the data being written/read? cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | although gold dust is precious, when it gets in your eyes, it obstructs | your vision. --hsi-tang ===============================================================================