22nd Aug 2024 | Number ⒃ Complement ?? | Leet ??????? Code ?? | Challenge ?? of the Day ??? (CoD) | DSA ???? Magic ???♂? | Daily ???
Finding the Boolean Operation for Flip (Complementing) Using Truth Tables

22nd Aug 2024 | Number ⒃ Complement ?? | Leet ?????? Code ?? | Challenge ?? of the Day ??? (CoD) | DSA ???? Magic ??♂? | Daily ???

???????? ???? ???? ?????????????????? ???????????? ?????????????? ?????? ???? ?????? ?????? ???????? ???? ?????? (?????? ????????) ???????????????? ????'?? ?????????? ???? ?????? ???????? ?????? ???? ?????? ??????????????. ???????? ???????? ???? ???????? ?? ????????. ?????? ?? ?????????? ???? ?????? ???????? ???????? ?????????????????????? ???? ?????? ?? ???????????? ???????????? ???????? ?????? ?????????????? ?????????? ?????? ?????????????????????? ???? ?????? ?????? ???????????? ???????????? ?????? ?????? ???? ???? ?????? ???????????????????????? ?????????? ?????? ???? ?????????????? ???? ?????? ?????? ??????????. ??????'?? ???????? ?????????? ????.

?????? ?????????????? ?????? ?????????????? ?????????????????????? ???? ????????????? ??'?? ?????????? ???? ???????? ??++ ???? ?????? ?????????????? ?????? ???????? ?????????????? ?????????????? ?? ?????????? ?????? ?????????? ?????????? ?????? ?? ???????????? ???????? ???????????????? ???? ???? ???????????? ???????????????????? ???????? ?? ???????????????? ???????? ????????????. ???????????? ???????????????????? ???????? ???????????? ???? ?????????????? ???????? ???????? ?????????? ???? ????????????'?? ???????? ?????????????????????????????? ???? ????????.

?????? ???????????????? ???????? ???? ???????????? ???? ???????????? ?? ???????????? ?????????? (?????? ??????). ???? ?????? ???????? ?????? ???? ?????? ???????????? ?? ???? ??. ?????? ???????? ?????????? ???????? ???? ???????????? ???? ?? ???????????? ???????? ???????? ???? ?? ???????? ???????? ???? ?????????? ?????? ?????????????????????????? ???????? ?????? ???? ?????? ???????????? ???????????? (?? / ??). ???? ???????? ?????????? ???? ?? ?????????? ???? ?? ^ ?? = ?????? ?????????????????? ?????????????????????????? ?????? ???? ???????? ???? ?????? ???? ?????? ?????????????? ?????? ???????????? ?????? ?????????? ???????????????????? ?????????? ?????? ?????? ???? ?????????????????????? ???? ?? ???????? (?? ????????) ?????????? ???? ???????? ?????? ???????? ?? ???????? ????.

???? ????????'?? ?????? ?????????? ?????????????????? ???? ?????????? ???? ??++ (???? ???????????????????? ?????????? ???? ????????):

  1. ???????? ?? ????????
  2. ?????????? ?????? ?? ??????????
  3. ?????? ?? ??????????
  4. ?????????? ?? ??????????
  5. ???????? ?????? ?? ??????????
  6. ???????????? ?? ??????????
  7. ???????? ???????????? ???? ??????????

Visual comparison of the number 0 represented in some of the types

??????'?? ???????? ?? ???????? ???? ?????? ?????? ?????????????? ???? ?????? ???? (?????????? ???????? ???????????????????? ???? ?????? ?????????? ???????????????????? ?????????????? ?? ?????? ?????????????? ??) ?????? ?????????????????????? ?????????? ???? (????????????????) ????????.

Bit Patterns of chars Capital A and Capital C | unsigned chars indistinguishable from numbers 65 and 67

?????? ?????? ?????????? ???? ???? ?????????? ???????????????????????? ???????????????? ??????????????? ?? ?????????????? ?????????? ???? ???? ?????????? ???? ???? ?????? ?????? ?????????? ?????? ???????? ?????? ???????? ???? ?? ???????? ??????. ???? ?????? ?? ???? ?????????????????? ???????????????? ?????????????? ?????? ?? ???? ?????????????????? ???????????????? ??????????????. ?????? ?????? ??????'?? ?????? ???? ???????? ???? ?????? ???? ?????? -????. ??????'?? ?????? ???????? ???????? ?????????? ???????? ????????.

Bit Patterns of the numbers 15, -15 and their sum under regular addition

?????? ???????? ?????????? ?????????????? ???????? ?????? ???????????????? ?????????? ??, ?????? ???????? ????? ???? ???? ???????????????? ?????? ???????????????????????????? ???? ?????? ???????????? -????. ?????????? ???????? ???? ?????????? ?????????? ?????????????? ???? ???????? ?????????? ???? ???????? ???? ???? ?????? ?????????????????? ????????, ?????????? ?????????? ????, ?????? ?????? ???????? ?????? ?????? ?????????? ?????? ???????????? ???? ?? ?? ?????? ?????????? ?????? -???? ????????.

???????? ?????????? ???? ???? ???????????? ?????? ???????????????????????? ???????????????????????????? ?????? -???? ?????????????? ???? ???????? ???????? ???? ???????????? ?? ?????????????????????? ?????????????????? ???????????????????? ?????? ???????? ?????????????? ?????????? ???????? ?????????????? ?????? ??????????????????. ??????'?? ?????? ???? ?????????? ?????????? ???????? ?? ????????????????????????????, ???????? ?????????? ?????????????? ???????????????? ?????????? ????????, ?????????? ???????? ????????. ???? ???? ?????? ?? ???????????? ???????? ???????? ???? ?????? ?????????????? ???????????? ???? ???????? ????'?? ???????? ?????? ?????????? ???? ??????????. ???? ???????? ???? ?????? ?? ?? ???? ?????? ???????????? ???????? ???? ?????? ?? ???????????? ???????????? ???? ?????? ?????? ???? ?????????????????? ?????? ???? ???? ???????? ?????? ???????? ?? ???????? ?????? ?????????? ????????.

????'?? ?????? ???????? ???????? ???????????? ?????????? ???????? ?????????????? ???? ?? ???? ???????? ??. ???? ???? ???????? ?? ???????? ???????? ???? ???? ???????? ???????? (?????????? ???? ?????? ???????????? ????) ?????? ?????? ?? ???? ???? ???? ?????? ???????? ???????????? ???????????? ???? ???? ?????????????????? ?????? ???? ???? ???????? ?? ?? ???? ?????? ???????????????? ???????????? ?????? ?? ???????????? ?????????? ???? ?????? ???????????? ?????????? = ???? (?? ^ ??) ???? ????????????. ?????? ???????? ???? ???????? ???????? ?????? ?????? ???? ???????? ?? ???????????????????????????? ???????? ?????????????? ???????? ???????????? ???????????? ???? ???????? ???? ?????? ???? (?????????? ???? ???????? ???? ???????? ???? ???????? ???? ???????? ???? ???????????? ???? ???????? -????).

Arriving at the 2s Complement Representation of -ve Numbers

?????? ???????? ???? ????????'?? ???????? ?????? ?????????????? ?????????????? ???? ???????? ???????????? ???? ???? ????. ???????? ????. ???????? ??????'???? ???????? ?????? ???????????? ?????? ?? ???? ?????? ???????? ??????.

???? ???????? 476. ???????????? ????????????????????

????????

?????? ???????????????????? ???? ???? ?????????????? ???? ?????? ?????????????? ?????? ?????? ???????? ?????? ???????? ?????? ?????? 0'?? ???? 1'?? ?????? ?????? ?????? 1'?? ???? 0'?? ???? ?????? ???????????? ????????????????????????????.

?????? ??????????????, ?????? ?????????????? 5 ???? "101" ???? ???????????? ?????? ?????? ???????????????????? ???? "010" ?????????? ???? ?????? ?????????????? 2.

?????????? ???? ?????????????? ??????, ???????????? ?????? ????????????????????.

?????????????? 1:

??????????: ?????? = 5

????????????: 2

??????????????????????: ?????? ???????????? ???????????????????????????? ???? 5 ???? 101 (???? ?????????????? ???????? ????????), ?????? ?????? ???????????????????? ???? 010. ???? ?????? ???????? ???? ???????????? 2.

?????????????? 2:

??????????: ?????? = 1

????????????: 0

??????????????????????: ?????? ???????????? ???????????????????????????? ???? 1 ???? 1 (???? ?????????????? ???????? ????????), ?????? ?????? ???????????????????? ???? 0. ???? ?????? ???????? ???? ???????????? 0.

?????? ???????????????? ?????????????? ?????? ???????????????? ?????????????? ???????????? ?????? ???????????? ?????? ???????? ???? ???????? ???? ???? ?????? ???????????????? ??????????????????. ???? ???? ???????? ?? ???????????? ???????????????????? ???? ?????? ???????????????????????? ?????????????????? ???????? ???????? ?????????? ???? ???? ???????? ?????? ???????? ?????? ?????????? ???????????? ???? ?? ????????????.

???????????? ???? ???????? ???????? ?????? ?????????????????? ??????'?? ?????? ???? ???????????????????? ???????? ?????????????? ???????????????? ?????????? ?????? ?????? ???? ?????????? ???? ???????? ???? ?????????????? ????. ???? ?????? ?????????????? ???????? ?????? ?? / ?? ???? ?? ?????????????? ??????????, ???????????????? ???? ???????????? ???? ??????'?? ???????? ???? ??????????????, ??????????'?? ?????????????? ?? ???????????? ???? ???????????????????? ?????? ??????????????????.

?????????? ???????? ???????????? ?? ???? ?????????? ?????? ?? ???? (?????? ?????? ??????-???????? ?????????????? ??????) ????????????. ???? ???? ?????????? ?????????????? ???????????????? ???? ?????????????? ?????????????????? ?????????????? ?????? ?????? ????????????????. ???????? ?????? ???????? ???? ?????? ?????????????? ???????????????????? ???? ?????????????? ?????? ?????????? ???????????????? ????????? ???? ?????? ??????. ??????'?? ???????? ???? ?????? ?????????? ???????????? ???? ???? ?????? ???????? ???? ???????? ???????? ???? ???? ??????????????????.

Bit Patterns of Numbers 65 and 15
Truth Table of OR (Boolean Operation)
Bitwise OR of 65 and 15
Truth Table of the Bit Flip Operation Exactly Matches that of XOR
Putting it All Together | Number Compliment | Bit Flip | Using XOR and Mask

???? ?????? ???????? ?????????? ?????? ?????? ?????? ?????? ?????????????? ?????????????????? ???? ?????????????? ???? ?????? ???? ???????????????? ?????? ???????????? ????. ?????? ?????? ???????????? ???????? ???? ???????????????? ?????? ?????? ???????????????? ?? ???????????? ???????? ?????????? ?????????????? ?????????????? ???????????????????? ???????? ?????? ???????? ???????? ??????????.

?????? ???? ?????? ?????? ?????????? ???? ???????? ?????? ?????????? ?????????? ?????? ???? ??????????????????. ?????? ?????? ???????????????? ??????'?? ?????????????? ?????????????????? ?????? ???????????? (?????????? ???????????????????? ???? ????????) ???????? ?????????????? ?????? ?????????????? (??????'?? ???????? ???? ?? ????????). ?????? ???????? ???? ?? ???????????????????? ?????? ???????????? ?????? ???????? ???????????????????????? ???? ?????? ?? ???????????????????? ????????.

?????? ???????? ?????????? ???? ???????? ?????? ?????????? ?????????? ???? ?????? ???????? (?????????????? ??????????????????) ???? ???????? ???? ???????????????? ?????? ?????????????? ?????????????? ???????????? ?????????? ?????? ???????? ???? ??? ?????? ?????? ?????? ???????? ???? ?????? ?????????? ?????? ????????. ?????? ???????????? ?? ???? ?????? ???????? ?????? ?? ???? ?????? ???????????? ???? ?????? ???????????? ???? ????????.

?????? ???? ???????? ???? ?????????? ?????????? ???? ?????? ?????????????? ?????? ?????????????? ??????????????????. ?????????????????? ???? ???????? ???? ?????? ???????? ?????? ???????????? ?????? ?????????? ?? ???????? ?????????? ?????? ???? ?????? ?????? ?????????????? ???????????? ?????? ????????'?? ????. ???????? ???? ?????????????? ???????? ?????? ???????????????? ????. ?????? ?????????????????? ?????????????? ???????? ???????? ?????????? ???? ?????????? ???????????? ???????? ???????? ????????????: ???????????????? ?????? ???????????? ???? ?????? ???????? ???? ??????.

?????????????????????????? ?????? ???????? ???? ?????? ?????? ???? ???????????? ???? ???????? ?????????????????? ?????????????? ?????????????????? ?????????? ???? ?? ???????????? ?????????????????????????? ???? ?????????? ?????????? ???????????????? ???? ?????? ????????????????????????. ?????? ?????????? ?????????????? ???? ?????? ???????????????? ?????? ???? ???? ???????? ?????? ???? ?????? ???????????? ?????? ???????? ????????????. ???????? ?????????????? ?????????????? ???????????????? ???? ???????????? ???? ?????? ???????????????? ?????????? ???? ???????? ??????????.

?????????????? ???? ???????????????? ?????????????? ?? ?? ???????????????????? ???? ???????? ???????? ?????? ?????? ???????????? ???? ???? ?????????????? ???? ?????????????? ???????? ?? ?? ?????? ?????????? ???? ???? ?????? ???????? ???? ?????? ?????? ???????????? ???? ?????? ???????????? ?????? ???????????????? ?? ???????? ????. ???????? ?????????? ???? ?????? ?????????? ???????? ???????? ???? ???????????????????? ?????? ???????????? ?????? ???????? ?????? ?? ???????????????????? ????????. ???? ?????? ?????? ?????? ???? ?????? ?????????????? ??????????.

Left Shifting 1 by the Bit Length of the Number
Subtracting 1 (aka 00000001) from the Bit Shifted Mask
Applying the Mask Using XOR
Putting it all together | Number Complement | Flipping the Bits

And so as promised here is the solution in Python for the problem.

Number Compliment | Solution | Python


要查看或添加评论,请登录

Krishna R.的更多文章