| | |
Binary Operation help.
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
Basically what my program does.
It has one main.
It has one function.
The function is:
Now res will use exclusive ^OR to compare two numbers in binary mode. But what do i do here to use res and and count how many 0s does res have?
I also need to call this function in the main, and then state that this many zeroes are in res.
Thank you for your help.
It has one main.
It has one function.
The function is:
C Syntax (Toggle Plain Text)
int humhum (unsigned long x, unsigned long y) { unsigned long res; printf("Enter an integer for x:"); scanf( "%ul", &x); printf("\nEnter an integer for y:"); scanf("%ul", &y); res = x ^ y; }
Now res will use exclusive ^OR to compare two numbers in binary mode. But what do i do here to use res and and count how many 0s does res have?
I also need to call this function in the main, and then state that this many zeroes are in res.
Thank you for your help.
This site might help : http://www.cs.plattsburgh.edu/~salva...bin_demo1.html
Happy programming!
Happy programming!
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
Well, try this one http://www.is.wayne.edu/olmt/binary/page3.htm
Don't you see a pattern that you can use to count the zeros?
Don't you see a pattern that you can use to count the zeros?
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
No wonder those links don't help. They have nothing to do with the problem.
First off, res is already binary. If you know the shift operator (<<), that makes it easy to count the 0's. Look it up and see what you come up with.
First off, res is already binary. If you know the shift operator (<<), that makes it easy to count the 0's. Look it up and see what you come up with.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- C++ TMoney Class - I Can't Figure This Out. (C++)
- Stack based Calculator (C++)
- StreamReader change Readline operation (VB.NET)
- How to generate a list of permutations for a given binary number (Java)
- Binary Search Tree MIPS (Assembly)
- Operation on Binary number, Need source code for elementar operation (+-*/) (C)
- long math problems (C++)
- adding numbers of binary output (C)
- binary search (C++)
Other Threads in the C Forum
- Previous Thread: sorting structure
- Next Thread: Creating a table in c
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi






