₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,921 members, 8,447,763 topics. Date: Saturday, 18 July 2026 at 10:50 PM

Toggle theme

Write An Algorithm To Add N Binary Numbers - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingWrite An Algorithm To Add N Binary Numbers (1510 Views)

1 Reply (Go Down)

Write An Algorithm To Add N Binary Numbers by Princefame1(op): 9:43pm On Jul 01, 2015
Programmers in the house help me answer the above question.
Re: Write An Algorithm To Add N Binary Numbers by Fulaman198(m): 1:04am On Jul 02, 2015
Not sure what the problem here is stated

some function would probably be

What are you trying to do?
Re: Write An Algorithm To Add N Binary Numbers by Princefame1(op): 4:02am On Jul 02, 2015
Fulaman198:
Not sure what the problem here is stated
some function would probably be
What are you trying to do?
. Is just an algorithm to add binary numbers..
Re: Write An Algorithm To Add N Binary Numbers by FincoApps(m): 5:34am On Jul 02, 2015
I suggest you try something first and show us. It would be wrong for people to just do the whole assignment for you. And what language are you working with ?
Princefame1:
Programmers in the house help me answer the above question.
Re: Write An Algorithm To Add N Binary Numbers by Princefame1(op): 10:33am On Jul 02, 2015
FincoApps:
I suggest you try something first and show us. It would be wrong for people to just do the whole assignment for you. And what language are you working with ?
I just need an algorithm to add binary numbers, dnt really need it in any programming language.
Re: Write An Algorithm To Add N Binary Numbers by FincoApps(m): 11:27am On Jul 02, 2015
Oh okay.
What I would do is
- Convert the numbers to decimal first (You can store 128, 64, 32, 16, 8, 4, 2, 1) in an int array and add all the indexes of 1s together
- Add the decimals together.
- Convert the result back to binary

Note: Converting to decimal with the above method works for numbers less than 256. If you want to make it better, you can create the array dynamically.

Princefame1:
I just need an algorithm to add binary numbers, dnt really need it in any programming language.
Re: Write An Algorithm To Add N Binary Numbers by Fulaman198(m): 12:43am On Jul 06, 2015
FincoApps:
Oh okay.
What I would do is
- Convert the numbers to decimal first (You can store 128, 64, 32, 16, 8, 4, 2, 1) in an int array and add all the indexes of 1s together
- Add the decimals together.
- Convert the result back to binary

Note: Converting to decimal with the above method works for numbers less than 256. If you want to make it better, you can create the array dynamically.
That's a start for him

a very good start

I advise that he proceeds from there.

So here is what he should do to begin:

Output: Ask user to enter a "x" number of values to be added
Input x
Output: Which decimal values would you like to add "y"
Input the decimals

Create a function like you stated to convert the decimal values to binary (an array preferably) in which

128 64 32 16 8 4 2 1 are utilised


Remember Binary is based on Power of 2 logic.

So for instance a Value like 225 would be 11100001 in Binary

I advise that he adds the values in decimal first before converting them to binary. That is easier that way in my opinion. There are different ways to go about this problem.
Re: Write An Algorithm To Add N Binary Numbers by Ogbeozioma: 6:32am On Jul 07, 2015
U can also convert to decimal by taking the binary digit and take the remainder when you divide it by 10 , that would give you the last digit, then multiply by 2power0, the get the next digit by dividing by 10 again and multiply by 2power 1. Continue doing this while the binary nuber is greater than zero. Then add everything. Hope yo got it.
Re: Write An Algorithm To Add N Binary Numbers by Ogbeozioma: 6:33am On Jul 07, 2015
U can also convert to decimal by taking the binary digit and take the remainder when you divide it by 10 , that would give you the last digit, then multiply by 2power0, then get the next digit by dividing by 10 again and multiply by 2power 1. Continue doing this while the binary nuber is greater than zero. Then add everything. Hope yo got it. This would convert larger number depending on you type of variable, but they should always be integer type.
Re: Write An Algorithm To Add N Binary Numbers by Princefame1(op): 10:26pm On Sep 17, 2022
@Wittylander,
I don't seem to get you contact number correctly.

I have some questions I need to get clarification on regarding the importation of laptops. Thanks.
1 Reply

Help Construct An Algorithm In Php CodeYour Toughest AlgorithmHelp Out With Algorithm To Add Multiple Numbers234

A Test For Python Guys. What Will This Code Do?Inventory Software (all Features Working) 100% - PhotosDetails On Spectranet Devices: The Promo, Monthly Subscription & How To Purchase