Thread: Reading binary files

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    That is, of course, how you want to interpret it. Obviously all data is stored in 0 and 1, because of how electronics work, but generally, everything "higher" then the hardware works in decimals, mostly base 10 or 16.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Elysia View Post
    That is, of course, how you want to interpret it. Obviously all data is stored in 0 and 1, because of how electronics work, but generally, everything "higher" then the hardware works in decimals, mostly base 10 or 16.
    You've completely lost me here. All digital electronics, with 0.01% exceptions [such as multilevel flash memory] works with the principle of two levels of input, and two levels of output. It is binary, all the way throug. It may be stored in lumps of 4, 8, 16, 32, 64, 128, 1024, or less often 3, 7, 24 or some other number of binary digits (bits) together. Occassionally, groups of 4 can be directly translated to "hex", but it's still 4 bits that just happen to mach base 16.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    That pretty much sums it up. When "working" with raw data, all we "see" is numbers, not digits. Perhaps that's clearer. Though it still hides the underlying concept.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Elysia View Post
    That pretty much sums it up. When "working" with raw data, all we "see" is numbers, not digits. Perhaps that's clearer. Though it still hides the underlying concept.
    Sure, working with binary streams of numbers becomes very unpractical very soon, so representing those binary streams with something more human readable and managable is a good idea. It's much easier to remember/deal with 0x1267 (hex), 011147 (octal) or 4711 (decimal) than it is to remember 0001001001100111. Or to deal with 'a' than 0x61 (hex), 0141 (octal), 97 (decimal), or 01100001. But they are all the same binary form inside the machine - we just represent the sequence of bits in various ways to make it more readable.

    And MOV EAX, ECX is much easier to read than 0x89 0xC8 [or 10001001 11001000 as the processor sees it].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #20
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Elysia View Post
    That pretty much sums it up. When "working" with raw data, all we "see" is numbers, not digits. Perhaps that's clearer. Though it still hides the underlying concept.
    numbers are made up of digits...

  6. #21
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Quote Originally Posted by robwhit View Post
    numbers are made up of digits...
    Lol, and digits defined within the constraints of the hardware(very low level) are known as either a 0 voltage and +5v or -5v and +5v depending on platform design.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a file in binary question
    By Dan17 in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 12:28 AM
  2. Reading Binary files
    By earth_angel in forum C++ Programming
    Replies: 10
    Last Post: 07-12-2005, 06:48 AM
  3. Reading data from a binary file
    By John22 in forum C Programming
    Replies: 7
    Last Post: 12-06-2002, 02:00 PM
  4. problem reading files in C
    By angelfly in forum C Programming
    Replies: 9
    Last Post: 10-10-2001, 11:58 AM
  5. Need Advice in reading files
    By jon in forum C Programming
    Replies: 4
    Last Post: 10-07-2001, 07:27 AM