convert double to binary format
49 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am currently working on a case and I would like to convert some numbers to the binary format. I can write them to a .bin file.
fid = fopen('test.bin','w','ieee-be');
fwrite(fid, 5, 'integer*4'); %5 is an example of the value that I would like to know the binary value of.
fclose(fid);
But actually I would like to be able to get this value in my workspace in stead of in a binfile.
For example when you convert an int to a double, you write:
X= double(y);
I would like to do the same, but then to binary.
Is this possible?
0 comentarios
Respuestas (2)
Walter Roberson
el 31 de En. de 2014
DoubleAsCharacters = char(typecast(YourDouble, 'uint8'));
Note: MATLAB does not store characters in ASCII form, which would involve using 8 bits per character. MATLAB uses 16 bits per character. In the above code I form one character (16 bits) for each byte (8 bits) of the binary representation of the double.
0 comentarios
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!