Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org [SOLVED] How to add two 4-bit numbers
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 01-16-2013, 11:50 PM #1 curious95 Member   Registered: Oct 2012 Location: /home/v Distribution: Slackware 14.0 Posts: 83 Rep: How to add two 4-bit numbers How do i add two four bit numbers, what are the steps required to do so?
 01-17-2013, 12:27 AM #2 linosaurusroot Member   Registered: Oct 2012 Distribution: OpenSuSE,RHEL,Fedora,OpenBSD Posts: 979 Blog Entries: 2 Rep: What kind of equipment is available? Are you looking for a chart of NAND gates or a line of a C program or what?
 01-17-2013, 12:37 AM #3 curious95 Member   Registered: Oct 2012 Location: /home/v Distribution: Slackware 14.0 Posts: 83 Original Poster Rep: No ,nothing like that, just how do i add two four bit numbers manually on paper. Like 0000 + 0001.
 01-17-2013, 12:58 AM #4 laho LQ Newbie   Registered: May 2009 Distribution: Debian, Ubuntu Posts: 12 Rep: 0000 0001 ---- 0001 It's the same like adding decimal numbers. The same rules apply.
01-17-2013, 01:10 AM   #5
curious95
Member

Registered: Oct 2012
Location: /home/v
Distribution: Slackware 14.0
Posts: 83

Original Poster
Rep:
Quote:
 Originally Posted by laho 0000 0001 ---- 0001
I don't think so i'm talking about binary addition(base 2). I don't know how to do it. But i could use an example showing me what to do.

Last edited by curious95; 01-17-2013 at 01:19 AM.

 01-17-2013, 07:18 AM #6 linosaurusroot Member   Registered: Oct 2012 Distribution: OpenSuSE,RHEL,Fedora,OpenBSD Posts: 979 Blog Entries: 2 Rep: In decimal when you get to 10 you write a single digit in the current column and carry 1 to the next column (left, more significant). Binary is just the same except it's 2 that brings you to the carry - there are only two single digits 0 and 1.
01-17-2013, 07:31 AM   #7
danielbmartin
Senior Member

Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,458

Rep:
Quote:
 Originally Posted by curious95 How do i add two four bit numbers, what are the steps required to do so?
There are on-line tutorials. This is a good one:
http://www.math.grin.edu/~rebelsky/C...student-binary

Daniel B. Martin

01-17-2013, 08:04 AM   #8
dwhitney67
Senior Member

Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,533

Rep:
Quote:
 Originally Posted by curious95 I don't think so i'm talking about binary addition(base 2). I don't know how to do it. But i could use an example showing me what to do.

Here's a few other examples:
Code:
```    0010
+   0101
------
0111

0011
+   0001
------
0100

0101
+   1011
-------
0000     <--- Note in this example, the most significant bit of the result rolled out of existence.```

 01-17-2013, 08:58 AM #9 sundialsvcs LQ Guru   Registered: Feb 2004 Location: SE Tennessee, USA Distribution: Gentoo, LFS Posts: 6,852 Rep: It's exactly like base 10: 0 + 1 = 1 ... etc[/b] ... 1 + 1 = 1 carry 1. It does take a bit of getting used two ... Last edited by sundialsvcs; 01-17-2013 at 08:59 AM.
 01-17-2013, 10:29 AM #10 linosaurusroot Member   Registered: Oct 2012 Distribution: OpenSuSE,RHEL,Fedora,OpenBSD Posts: 979 Blog Entries: 2 Rep: http://cowbirdsinlove.com/43
 01-17-2013, 10:32 AM #11 suicidaleggroll LQ Guru Contributing Member   Registered: Nov 2010 Location: Colorado Distribution: OpenSUSE, CentOS Posts: 5,217 Rep: It's the same as adding in any other base. Base 2, base 8, base 10, base 16, it all works the same. Start at the LSB, add the numbers together. If you overflow that digit (2 in base 2, 8 in base 8, 10 in base 10, etc), then carry the 1 into the next most significant column and repeat.
01-17-2013, 10:33 AM   #12
suicidaleggroll
LQ Guru

Registered: Nov 2010
Distribution: OpenSUSE, CentOS
Posts: 5,217

Rep:
Quote:
 Originally Posted by linosaurusroot http://cowbirdsinlove.com/43
lol, clever

 01-17-2013, 10:36 AM #13 273 LQ Addict Contributing Member   Registered: Dec 2011 Location: UK Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs Posts: 5,760 Rep: Like the much repeated phrase "There are 10 types of people in the world: those that understand binary and those that don't.".
 01-17-2013, 01:07 PM #14 curious95 Member   Registered: Oct 2012 Location: /home/v Distribution: Slackware 14.0 Posts: 83 Original Poster Rep: Thank you, i've understood what to do Sorry laho guess i thought binary addition would be 'harder' than that. Last edited by curious95; 01-17-2013 at 01:14 PM.
01-17-2013, 08:49 PM   #15
Senior Member

Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,492

Rep:
Quote:
 Originally Posted by curious95 Thank you, i've understood what to do Sorry laho guess i thought binary addition would be 'harder' than that.
Try subtraction

 Tags bit

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post MinuPriya Linux - Newbie 5 08-11-2010 12:31 AM vibinlakshman Programming 1 02-21-2009 02:10 PM rajesh_b Programming 3 09-15-2006 09:03 AM Tengil Linux - Newbie 3 03-04-2004 12:58 PM bamalabs Programming 3 01-20-2004 09:59 AM

All times are GMT -5. The time now is 01:50 PM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -