Hex to Num / Hex Cell Array
Mostrar comentarios más antiguos
Hello I have a hex cell array and I indexed them.
For example I have 'A7' and when I use hex2dec, it gives me nonsense result which is -7.7452e-121. how can I get exact result? I mean I want to see that hex A7 = decimal 167.
Thank you.
6 comentarios
Chunru
el 3 de Jun. de 2022
Can you show your cell array?
Rik
el 3 de Jun. de 2022
Please post code that reproduces this issue. You can run code within the editor to make sure the effect matches what you see in your local copy.
tinkyminky93
el 3 de Jun. de 2022
tinkyminky93
el 3 de Jun. de 2022
hex2dec('A7') % what you should have used
hex2num('A7') % what you actually used
The unfortunately named NUM2HEX and HEX2NUM convert to/from the IEEE 754 floating point hexadecimal representation, they are completely unsuitable for your task. Just for interest, the complete hexadecimal is:
num2hex(hex2num('A7'))
Apparently someone thought that it would be a good idea to pad its input with trailing zeros. Ugh.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Type Conversion 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!