perlperl
asked on
writing data in binary form
In my large C++ application, I see often times previous developers have written data in binary form. So basically when they have to read they convert it to ASCII form as they know the format of the file, (example 1st 4 bytes are uint32_t, next byte is char etc....)
I am trying to understand what is the benefit of writing in binary form and then when it comes to reading, reconstruct the original human readable form?
Is there any benefit like size reduction by saving in binary form, or faster write processing etc or maybe something else?
P.S: Again these files are only configuration related file like metadata of a file etc...
I am trying to understand what is the benefit of writing in binary form and then when it comes to reading, reconstruct the original human readable form?
Is there any benefit like size reduction by saving in binary form, or faster write processing etc or maybe something else?
P.S: Again these files are only configuration related file like metadata of a file etc...
ASCII form is just for humans to be able to read it. All arithmetic is done in binary form as is all addressing including things like memory, MAC, and IP addresses. Binary is the original and necessary format, not ASCII.
ASKER
I am talking about the contents of files stored on filesystem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Now I got it.
In my case it was more for size reduction. The file was mainly storing uint32 only. and the file had a limit of 4K only. So by saving binary instead of ASCII we can fit more entries in the file.
Thanks a lot.
In my case it was more for size reduction. The file was mainly storing uint32 only. and the file had a limit of 4K only. So by saving binary instead of ASCII we can fit more entries in the file.
Thanks a lot.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the information,
I did see the ntohl and htonl in my application while storing/reading data to/from the file
I did see the ntohl and htonl in my application while storing/reading data to/from the file