![]() |
|
#1
|
|||
|
|||
How to do logical and arithmetic operations?I am trying to do logical and mathematical operations in C in a bit level. I want to do sum, subtraction, AND, XOR and OR operations, but the only information that I got about this subject is the code that in the txt file, and I quite don't understand how the last function (void showbits) is converting the number from the hexadecimal to the binary form.
So if someone can tell me how the last function is doing the process of converting the typed number and give me a very good idea about how I can do logical and mathematical operations in the binary level I would be very pleased. Thanks in advance |
|
#2
|
|||
|
|||
|
I do not want to look as if I am self promoting my self or site, but I've written a little tutorial over bitwise operators (yes Walt and dsmith, I finally figured them out
) which you can find here, if that helps at all. It also includes code to add and subtract using only bitwise operators. |
|
#3
|
||||
|
||||
|
Quote:
My new mantra: Read the Sticky It's for all who post questions... __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#4
|
|||
|
|||
|
Quote:
Thanks, the part of shift helped to understand a little more, but I still have a lot of doubts regarding other parts. I made a modified version of your program that looks like this: CPP / C++ / C Code:
I am not sure if I really understood the concept of the carry bit and how I can show the result of the sum in binary? P.S: And how I can put my code inside one of these special code regions? Last edited by LuciWiz : 04-May-2005 at 00:12.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#5
|
|||
|
|||
|
Quote:
Quote:
CPP / C++ / C Code:
And finally, you can use [ c][/c ] tags (without spaces) to format your code all purdy like. |
|
#6
|
||||
|
||||
|
I repeat:
Read the Sticky It's for all who post questions... including lontra __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#7
|
|||
|
|||
|
Thanks Dr. Evil, no more doubts.
WalterP, after had read your first message I gave a quick read in the sticky and didn't perceive anything wrong with my messages. I assume that you was talking about the lack of formatting of the code, right ? If this is the case, at the time I didn't know that this option existed, and soon after had read the second message of Dr Evil I realized it and asked him how to use it. |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The