Shrink Your File Format

August 8, 2007

Want to shrink the file format in your program?  Here’s a method for shrinking your numbers down.  If you write the number “127″ to a file, you are writing three bytes to the file (the ASCII character for each number).  This might not seem like a big deal, but in the long haul you can save a ton of space using the following method.  Write the character for 127 (\x7f, but printed as ).  Now read the file’s charachter and convert it into a number.  You just saved two bytes.  For writing numbers bigger than 256 (ASCII limit), write partials of numbers.  Break these numbers up in parts of two (589406830=58|94|06|83|0).  It might not be the most efficient way to shrink these numbers down, but it is easy to code and could save space in the long run.  If you want to shrink your numbers even more, convert them to hexadecimal before writing them to a file (hex was originally designed to write huge numbers).  Read these suckers back, feed it all into one string, and convert the string to an integer.  Congratulations on shrinking your file format.

Entry Filed under: Computers, Hacking, Math, Programming, Scripting, Software, Technology, Tips. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


 

August 2007
M T W T F S S
« Jul   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Archives

Categories

RSS The Nerdcan

Contact

vainentree@gmail.com