Convert unsigned integer to decimal

44 visualizaciones (últimos 30 días)
Tony
Tony el 7 de Dic. de 2021
Comentada: Steven Lord el 7 de Dic. de 2021
I have two unsigned hex values, 9d900000, and 0000, which are suposed to be unsigned intergers: 32 bit and 16 bit, respectively.
I'd like to convert both of these from unsigned int to decimal format. I have this code converting the two to their unsigned format, but I am unsure how to then convert it to decimal. Thanks in advance!
int1 = uint32(9d900000);
int1 = uint16(0000);

Respuestas (1)

James Tursa
James Tursa el 7 de Dic. de 2021
Editada: James Tursa el 7 de Dic. de 2021
Not sure what the real question is here. Does one of these do what you want?
int1 = uint32(hex2dec('9d900000'));
int1 = uint32(0x9d900000);
You can always convert the result to double if you want.
  1 comentario
Steven Lord
Steven Lord el 7 de Dic. de 2021
Your second line of code can be simplified.
x1 = 0x9d900000u32
x1 = uint32 2643460096
Check:
x2 = uint32(0x9d900000)
x2 = uint32 2643460096

Iniciar sesión para comentar.

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by