Questions tagged [complement]

This tag is deprecated! Use more specific tags instead: For the binary representations of negative values in computer science, use tags [ones-complement] and [twos-complement]; For the bitwise complement operation, use [bitwise], or [regex-negation] for the use of complement patterns in regular expressions, or [bit-manipulation] for complementing said data.

This tag is deprecated! Please consider use of the following tags instead:

112 questions
-2
votes
1 answer

how to find complement in two lists

There are two phones, phoneA and phoneB, how to how to find complement in phoneB but not in phoneA, one ex; phoneA = ["long lasting battery”, ”clear display”, ”great camera”, ”storage space”], [“clear display”, ”long lasting battery”, ”great…
-2
votes
3 answers

Why 1s complement is -2

int main() { int a=1,b; b=~1; printf(""%d",b); return 0; } pls explain by showing bitwise operation it will be helpful to understand... thanks in advance.......
gourab
  • 1
-2
votes
1 answer

complement/negation doesn't work right

hello i wrote a small program to demonstrate the problem that i'm facing long n; n = 1; //1=0001 //2=0010 //-2=1101 Console.WriteLine(n+" "+ ~n); Console.WriteLine(n+~n); and the output is something like this : 1 -2 -1 as i know ~ sign…
Mohammad Hossein Amri
  • 1,842
  • 2
  • 23
  • 43
-3
votes
2 answers

uint(0) - uint(1) output maxValue of uint64

Can anybody tell me why the output is not -1 but 18446744073709551615? package main import ( "fmt" ) func main() { a := uint(0) b := uint(1) fmt.Println(a - b) } output 18446744073709551615 currently, my understanding is the…
-3
votes
2 answers

How to check whether a number is binary or 2's complement in C?

I was making a binary adder in C using only logic gates. Now for example, I wanted to add 4 + (-5) so I would get the answer in 2's complement and then convert it to decimal. In the same way, if I do, 4 + (-3) I would get the answer in binary and…
Box Box Box Box
  • 5,094
  • 10
  • 49
  • 67
-3
votes
2 answers

Signed magnitude and complement

I need to know how to solve this problem please Represent the following decimal numbers in binary using 8-bit signed magnitude, one’s complement, and two’s complement: 88 -76 My solution is : 88 = 01011000 8 bit sm 10100111 1s…
Ali
  • 1
  • 1
  • 2
-3
votes
1 answer

how do I convert a base ten representation to its equivalent two's complement in 7 bit?

how do I convert a base ten representation to its equivalent two's complement in 7 bit? I am learning applications of discrete mathematics and this is one of the questions, being new to this, I just don't understand
1 2 3 4 5 6 7
8