MATLAB Answers

Negitive number from a hex value

조회 수: 56(최근 30일)
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

Duke
Duke 4 Feb 2014
Anyone know anything about this, or understand what I'm asking?

댓글을 달려면 로그인하십시오.

채택된 답변

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

  댓글 수: 0

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Thomas
Thomas 4 Feb 2014
편집: Thomas 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.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

태그


Translated by