How does fread bring in a signed integer?
Mostrar comentarios más antiguos
Hello,
I am working with the reading in of binary files and I had a question on the fread function.
Basically, the datagram format specifies that the data samples are stored as signed 16bit integer (2's compliment). From looking around, there are a number of methods for handling signed numbers (2's compliment, 1's compliment, signed magnitude, offset...). So when i use fread() as follows:
s = fread(fid,256,'int16',0,'b');
Are the numbers read in as 2's compliment binary, or signed magnitude, or something else? I have to image it matters but I can't find what method MATLAB uses.
Thanks for any and all help!
1 comentario
Rik
el 19 de Feb. de 2019
I couldn't find it in the doc either. IIRC almost everyone uses 2's complement, so I would assume Matlab does as well. You can read bit by bit if you want to make sure either way. There are only 2^16-1 numbers you need to check, which shouldn't take more than a few minutes to check.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Data Workflows en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!