Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3278
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Binary file: SAT |
| Date | 2011-04-20 19:02 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <4fa8adc3b92c44287a399f6cb1aab3ff@ruby-forum.com> (permalink) |
| References | <f82185e10f19c74e1962c03aeccd4771@ruby-forum.com> |
Alessandro Barracco wrote in post #994136: > Hi all. I never work before with binary file, and I'm a bit > confused..... > Both numbers and characters are stored as integers in file(or anywhere on a computer). One method of storing characters in a file is with the ASCII encoding. For instance, in the ASCII encoding 'a' is stored as the integer 67, taking up one byte total. Note that you could also store the integer 67 in 4 bytes--the other three bytes would just be all 0's. You may also want to store the count of the number of banks in New York, which is 67. You could also store that in one byte. So the question becomes, how do you know whether a 67 you read from the file is supposed to be the count of banks or the letter 'a'? The answer is: you have to know how the data in the file is supposed to be interpreted. If the integer in the first byte in a file is supposed to be an integer, than you read in the integer as is; and if the integer in the second byte in the file is supposed to be a letter, then you need to convert the integer to a letter. In other words, you have to know what each byte in the file is supposed to represent. -- Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Binary file: SAT Alessandro Barracco <bomastudio@gmail.com> - 2011-04-20 17:00 -0500
Re: Binary file: SAT 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-20 19:02 -0500
Re: Binary file: SAT 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-20 19:45 -0500
Re: Binary file: SAT Roger Braun <roger@rogerbraun.net> - 2011-04-20 21:53 -0500
Re: Binary file: SAT Alessandro Barracco <bomastudio@gmail.com> - 2011-04-21 03:06 -0500
Re: Binary file: SAT 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-21 12:25 -0500
Re: Binary file: SAT Alessandro Barracco <bomastudio@gmail.com> - 2011-04-22 04:51 -0500
Re: Binary file: SAT 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-22 13:49 -0500
Re: Binary file: SAT William Rutiser <wruyahoo05@comcast.net> - 2011-04-23 13:20 -0500
Re: Binary file: SAT 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-21 12:53 -0500
csiph-web