uint32 and uint64 binary display

조회 수: 18 (최근 30일)
William
William 2012년 3월 14일
When using the uint32 and uint64 command as in
Answer = uint32(137)
I still get 137 back and not a binary number 32 bits long. Is there a way to output a 32 bit or a 64 bit binary number which I can then perform operations on and get a binary number returned?
Thanks

답변 (2개)

Walter Roberson
Walter Roberson 2012년 3월 14일
No.
There are a few commands such as bin2dec() and dec2bin(), but there are no other MATLAB routines defined on strings or numeric vectors that happen to represent binary.
The binary operations such as bitxor() work on unsigned integers or arrays of unsigned integers.
uint32(137) does not mean that the value 137 is to be represented as a 32 bit binary string: uint32(137) means that the value is to be treated as an unsigned integral datatype consisting of 32 total bits. "integral datatype" just like Fortran's INTEGER or C's int .

Jan
Jan 2012년 3월 15일
uint32(137) does reply a binary 32 bit value. It is only displayed as a decimal when printed to a file or the command line. You can perform operations on this value as expected:
disp(uint32(137) - uint32(1000))

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by