473,408 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

to find complement of a number

hi,
I just want to know how to find complements for a number.
These are the following answers for complements
2's complement(10110)=01010
4's complement(1230)=2110
5's complement(4322)=0123
please tell me how to do it.how this answers comes.This is a global
edge question.
please also tell me how to find 8's complement(7436)
please alos tell me how to find 3's,4's,5's,6's,7's,8's complements.
regards
vijay

Mar 25 '07 #1
3 7547
On 2007-03-25 09:33, vi*************@gmail.com wrote:
hi,
I just want to know how to find complements for a number.
These are the following answers for complements
2's complement(10110)=01010
4's complement(1230)=2110
5's complement(4322)=0123
please tell me how to do it.how this answers comes.This is a global
edge question.
please also tell me how to find 8's complement(7436)
please alos tell me how to find 3's,4's,5's,6's,7's,8's complements.
Doesn't you textbook tell you that? And have you tried google? And what
part of the questions concern C++? (Perhaps comp.programming would be
more useful.) Before making your next post take a little while to read
http://www.parashift.com/c++-faq-lite/how-to-post.html, sections 5.2 and
5.9 might be of special interest.

--
Erik Wikström
Mar 25 '07 #2
Hi there,

The principle of making a compliment number is quite simple like
binary calculation.

If you wanna make a 2's compliment of 10110, it is 01010 because when
you make a sum of 10110 and 01010 , the result becomes 100000.
However, the digits were only 5 bits so we don't care about the 1 in
the front. In addition, both number must be based on the same number
system.

I apologize about my bad explanation =P

Here is another example...

Let's do the 8's complement of 7436. 7436 is a number of base 8 so try
to make 1 0000 in this time.

7436(8) + 4(8) = 7440 (8)
7440(8) + 40(8) = 7500 (8)
7500(8) + 500(8) = 10000 (8)

so the 8's complement of 7436 is 0544(8).

Does it make sense to you?

I hope you understand this.

Cheers,
On Mar 25, 5:33 pm, vijaybaskar3...@gmail.com wrote:
hi,
I just want to know how to find complements for a number.
These are the following answers for complements
2's complement(10110)=01010
4's complement(1230)=2110
5's complement(4322)=0123
please tell me how to do it.how this answers comes.This is a global
edge question.
please also tell me how to find 8's complement(7436)
please alos tell me how to find 3's,4's,5's,6's,7's,8's complements.
regards
vijay

Mar 25 '07 #3
You're little bit mean, mate =P Quire right though. =)

Cheers,

On Mar 25, 7:51 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-03-25 09:33, vijaybaskar3...@gmail.com wrote:
hi,
I just want to know how to find complements for a number.
These are the following answers for complements
2's complement(10110)=01010
4's complement(1230)=2110
5's complement(4322)=0123
please tell me how to do it.how this answers comes.This is a global
edge question.
please also tell me how to find 8's complement(7436)
please alos tell me how to find 3's,4's,5's,6's,7's,8's complements.

Doesn't you textbook tell you that? And have you tried google? And what
part of the questions concern C++? (Perhaps comp.programming would be
more useful.) Before making your next post take a little while to readhttp://www.parashift.com/c++-faq-lite/how-to-post.html, sections 5.2 and
5.9 might be of special interest.

--
Erik Wikström

Mar 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Abby | last post by:
I have an array which contain Hex no. in each position. For examples, unsigned char data; data = 0x00; data = 0x01; data = 0x02; data = 0xE; data = 0xEF; --> This is the checksum value
8
by: Mantorok Redgormor | last post by:
From least to greatest is it sign magnitude ones complement two's complement Where sign magnitude is the least way to represent integers and two's complement is the best way to represent...
33
by: Daniel Fadlun | last post by:
Is there a bigger, mathematical, data type in C than the double (64 bit) one or the old long double (80 bit)? I'd like to add precision to my mathematical application, but I can't figure out how....
3
by: Janice | last post by:
I got this question from my textbook and I cannot understand the theory. When a signed positive integer X divided by pow(2,k), the result is shifting k bits to right and putting w-k bits of 0 from...
7
by: Greenhorn | last post by:
Hi, Is two's complement always used as a storage method or is it computed while computing the expression involved. e.g., int a = -2, b = 3, c = 4, d; d = b - c; Here, is 'a' stored as two's...
5
by: sankar | last post by:
Hi, I am using a Q14.18 value. There are tables used in my program which are being indexed by the exponent and mantissa parts of the corresponding floating point value. So how can I get the...
3
by: Marc | last post by:
I'm trying to set the first three bits to zero on a byte. For some reason, the compiler is casting the number peculiarly when I use the bitwise complement operator. Here's what I think should...
22
by: sarathy | last post by:
Hi all, I have a few doubts in the 1's and 2's complement representation. Generally negative numbers can be represented using either 1's complement or 2's complement representation. 1's...
14
by: darthghandi | last post by:
What would be the most efficient way to calculate the two's complement of a variable length byte array? Thanks for your time.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.