Hi!
I have a question regarding type conversion and memory storage. I’ve looked around after functions for appropriate conversion, but haven’t found any yet.
What I’m tring to do is to convert double, int and strings to binary format. Or more pricesely to the format used to store these types in memory. In C++/Java this is known as the byte-type. For instance, a int would be stores as four consequtive bytes in memory.
I’m found diverse functions like decbin(…), base_convert(…), pack(…), etc., but no functions that can help. So, to precisely define the problems:
– Coversion of a int to a byte array (4 bytes, little endian)– Coversion of a double to a byte array (8 bytes, little endian)– Conversion of a string to a byte array (x bytes)– Write these the contents of these arrays to file (binary files)
Does anyone has any suggestions on how this may be done? Really appreciated!