hex2dec return error
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
>> hex2dec(238a)
hex2dec(238a)
↑
Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced
delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
0 commentaires
Réponses (2)
Steven Lord
le 2 Juin 2020
>> x = 0x238a
x =
uint16
9098
2 commentaires
James Tursa
le 3 Juin 2020
Modifié(e) : James Tursa
le 3 Juin 2020
If you are reading a 2's complement hex pattern for a known sized integer, you can just use the simple test you proposed. You could of course typecast the result into a signed integer and then check the sign, but it will give you the same result as the simple test you proposed. If you actually need the value, then just:
u = the unsigned uint16 number
s = typecast(u,'int16'); % the signed int16 number with same bit pattern as u
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!