I just finished a computer organization course, in which we learned that all files and data are stored in the form of 0’s and 1’s (bits). However, I’m curious how a programmer can actually access a file’s binary representation? That is, how can I see (or access) the 0’s and 1’s that represent any file on my computer?
I just finished a computer organization course, in which we learned that all files
Share
While it’s true that at the most basic level, everything is stored as bits, most processors these days only allow you to access bytes (8 bit blocks). From a byte, however, you can figure out if a bit is one or not.
To get the value of a bit in position
pos(from least significant bit, 0, to most significant bit, 7) of bytebyte, you could use this code (in C, here, but it’s likely valid in many languages):