domingo, 29 de septiembre de 2013

Save data like binary format less weight in disk (integer data)

Sometimes us want save number data (integer or dbl number). However integer numbers are lightweight in disk, in fact if you want save this numbers in binary file, I think you should wonder why?. This is because no the integer data use decimals therefore exist the answer, yes, the dbl numbers are heavy becuase it use decimal numbers.
One morning when I was take my deskfast in my work (I think that because I work in one proyect where I needed save data from inclinometer and then save it in binary files) I think How Save my information from inclinometer in lightweight binary file?, I was trying all methods (Or I thought this)

-String, number, dbl
-String, hexadecimal, dbl
-String, array number, array dbl

In these methods the result was the same: 8-14 Mb per file thus Was the issue?, Well the problem wasn't in all my strings process, the problem was in the DBL data, and I thought, "Well If I trying omit dbl datas then may be I saw differents effects In fact the solution was the next:

I received the numbers in string format, well the next step was convert it in bdl datas (because this information was decimal data) and then the next step was convert this in integer data. And the next question follow me: Who can convert dbl in integer data? If my information was decimal numbers. Well the solution is more more easy and this is the next:

The string of numbers only multiply per 100, and this way I had integer numbers, for example:

(635.5)(100) = 63550

Very nice I said xD I was found the solution for my problem.

Well I share my experiencie because I think that most of people was the same problem.I presume.
This files weighed 2 MB per file per 86400 data of numbers




No hay comentarios:

Publicar un comentario