문제

In MATLAB R2011b it is not possible to process bit-and operation if any of numbers is negative. In Java it would be something like: -25 & 15 = 7. How is it possible to get something similar in MATLAB? Tried to convert to uint32 before operation, but uint32(-25) = 0 in MATLAB.

도움이 되었습니까?

해결책

You can use the bitand operation:

intout = bitand(-25, 7, 'int32')

On R2011b, -25 is bit-wise equivalent to (2^32)-25 if you consider uint32. So you can try:

intout = int32((2^32 - 25) & 7)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top