Negitive number from a hex value

15 Ansichten (letzte 30 Tage)
Duke
Duke am 29 Jan. 2014
Beantwortet: Walter Roberson am 4 Feb. 2014
If I go into the windows calculator and type in -69 in decimal and I convert that to hex I get FFFFFFBB. If I go into MatLab and I type int32(hex2dec('FFFFFFBB')) I get 2147483647. Is there any way that I can take a hex value and get the negative representation of the value, so I’d like FFFFFFBB in MatLab to give me -69. Thanks!
  1 Kommentar
Duke
Duke am 4 Feb. 2014
Anyone know anything about this, or understand what I'm asking?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Feb. 2014
typecast(uint32(hex2dec('FFFFFFBB')),'int32')

Weitere Antworten (1)

Thomas
Thomas am 4 Feb. 2014
Bearbeitet: Thomas am 4 Feb. 2014
2147483647 is Maximum integer value in matlab
you can get that by typing
intmax
so the answer you are getting is not value out of hex2dec but the intmax.
You can use Two's complement to represent negative numbers.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by