uint32 and uint64 binary display
19 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Walter Roberson
on 14 Mar 2012
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 Comments
Jan
on 15 Mar 2012
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 Comments
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!