![]() |
|
#1
|
|||
|
|||
Please help Problem with binary addition.Hey,
I really need help with binary addition. My program excpets 2 int numbers then it converts them to binary and display them in 8 bit multiples. Now I am trying to add the binary numbers together. I have to do this using binary addtion. I have written a function called binAddCal but it isn't working. When I run my program I don't get any errors but binAddCal doesn't produce any results. Thanks. binAddCal is the last function in the code. CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: Please help Problem with binary addition.Quote:
If a function "isn't working", make the program tell you why: put cout<< statements at strategic places to see what the program is seeing at that time: Look at the function binAddCal. Why wouldn't it print something? Well, does it even go through the loop? You could try something like this before the loop: CPP / C++ / C Code:
If it turns out that the sizes are not what you expect, then make the program tell you what is passing to the function. In main(), you could do something like: CPP / C++ / C Code:
Regards, Dave |
|
#3
|
|||
|
|||
Re: Please help Problem with binary addition.Thanks Dave,
I tried what you said and it is telling me that the sizes are 0 but I don't understand why the vector array isn't being pass by the function. |
|
#4
|
|||
|
|||
Re: Please help Problem with binary addition.Quote:
Maybe something like this. CPP / C++ / C Code:
|
|
#5
|
|||
|
|||
Re: Please help Problem with binary addition.Thanks everyone for your help. I figured it out. I just had to convert in main instead of trying to use a funtion.
Thanks |
|
#6
|
|||
|
|||
Re: Please help Problem with binary addition.Quote:
If you are happy with that solution that is fine. There is a solution that will let you use your functions. The issue was that you were passing a copy of the vector not the actual vector. So any changes made to the vector in the functions were to a copy of the vector and the copy was destroyed on function exit. So you need to pass the vector in a way that it is not a copy. |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Graphic problem in Unreal Tournament 2004 | zerox | Computer Software Forum - Games | 10 | 09-Oct-2005 13:31 |
| Runtime Problem involving "printf" in C Program | supamakia | C Programming Language | 2 | 09-Oct-2005 11:09 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 08:03 |
| String problem | vaha | C Programming Language | 3 | 24-May-2005 19:21 |
| Please help! Dynamic binary tree problem | robsmith | C Programming Language | 3 | 15-Mar-2005 22:20 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The