How can I write a function that takes as input a vector of 8 bit signed integer in twos-complement and represen the negation of the input

How can I write a function that takes as input a vector of length eight containing 0s and 1s and representing an 8 bit signed integer in twos-complement. The function should return a vector of eight 0s and 1s representing the negation of the input.
note: I'm not allowed to use loops

댓글 수: 1

Hi Sean,
Have you found an answer for this? Am looking for the exact same step.
Thanks and regards

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

답변 (1개)

bin2dec, can turn a binary string into a decimal number. I suggest you then cast it as:
int8
dec2bin can then turn a decimal number into a binary string.

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 3월 4일

댓글:

2020년 6월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by