Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: 7stud -- Newsgroups: comp.lang.ruby Subject: Re: Binary file: SAT Date: Thu, 21 Apr 2011 12:53:38 -0500 Organization: Service de news de lacave.net Lines: 21 Message-ID: <00a061658a9946c7c43c68a0fe83f318@ruby-forum.com> References: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303408439 72679 65.111.164.187 (21 Apr 2011 17:53:59 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Thu, 21 Apr 2011 17:53:59 +0000 (UTC) In-Reply-To: X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382014 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <00a061658a9946c7c43c68a0fe83f318@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3327 Suppose your file contains this data: "\x00\x00\x00\x01" Scenario 1: The four bytes could represent the number of widgets sold (=1). Scenario 2: Or the first two bytes could represent the number of widgets sold(=0), the third bytes is the number of widgets in inventory(=0), and the fourth byte is the number of widgets in transit to the factory(=1). So unless you know what each byte in the file is supposed to represent, you cannot read the file correctly. If someone hands you the file with the above data in it, and says, "Here's your data. Get cracking!", and the person walks out the door, how would you know if Scenario 1 or Scenario 2 is the way the data is laid out? -- Posted via http://www.ruby-forum.com/.