uint32 and uint64 binary display
19 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
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 .
0 个评论
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))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!