Input as the hexadecimal number

30 visualizaciones (últimos 30 días)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan el 11 de Ag. de 2016
Respondida: Stephen23 el 26 de Abr. de 2022
Is it possible to enter directly the hexadecimal number without the conversion to decimal number and perform all the hexadecimal operation like AND,OR, XOR?
For example a = 0x53656174 , b = 0x454B5350
c = bitand(a,b)
how to represent the hexadecimal number in matlab?

Respuesta aceptada

Guillaume
Guillaume el 11 de Ag. de 2016
Editada: Guillaume el 11 de Ag. de 2016
Unfortunately, there is no support for hexadecimal literals. The best you can do is:
a = hex2dec('3656174');
b = hex2dec('454B5350');
However, there is support for displaying in hexadecimal:
format hex
c = bitand(a, b)
  1 comentario
Hoa Lu
Hoa Lu el 30 de Nov. de 2021
Thanks for your tips.
BTW, how about the floating point format such as single (float32), double (float64), or CustomFloat?

Iniciar sesión para comentar.

Más respuestas (1)

Stephen23
Stephen23 el 26 de Abr. de 2022
Since R2019b it is possible to directly enter literal hexadecimal and binary numeric values:
0x2A
ans = uint8 42
0b101010
ans = uint8 42

Categorías

Más información sobre Characters and Strings 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!

Translated by