Most compact way to store numbers in a file?
Posted on 2010-08-13
I want to create a file which uses as little space as possible. The contents of the file will be numbers, ranging from 0 to 1,000,000,000,000, and then ascii alphas.
The format of the file will look something like this:
and so on (there will be no line breaks, it will be one long stream). Would representing the numbers as a single char per digit be more efficient than representing the entire number as an int? I mean storing the number "50" requires two bytes, one for each digit, as characters. If I wrote it as an int, it will require 32 bytes, right?