ASCII and Different Bases

This is a discussion on ASCII and Different Bases within the C++ Programming forums, part of the General Programming Boards category; Hey,
Someone said in another message that a text file is a string of 3 digit numbers representing the letters ...

ASCII and Different Bases

Hey,
Someone said in another message that a text file is a string of 3 digit numbers representing the letters and symbols (I know when it gets to the hard drive though it's binary). If you converted ASCII’s three digit numbers to hexadecimal, for example, then wrote the hex directly into a binary file would that mean the file is smaller than the original ASCII? If "m" in ASCII is equal to 109, then in hex it would equal 6D. Wouldn’t this use one letter space less of memory?

If you write text to a file in binary mode, the size of the file would stay the same (each character takes up one byte).

If you write numbers to a file in binary mode (for example, int, float, double), then the size of the file would almost always become smaller, because an int, float, or double, or other number in memory is always a fixed size. For example, typical sizes for numbers:

int - 4 bytes
float - 4 bytes
double - 8 bytes

for C++ streams, to write files in binary, open the file in binary mode, then use write() and read() to write or read in binary.

Yeah...To be stored in a hard drive, every number base must be converted into binary. Even if 109 is more decimal digits than 6D is, it is still converted into the binary form, which ends up being the same value.