| | |
Help with C bitwise code
Thread Solved |
•
•
Join Date: Sep 2005
Posts: 12
Reputation:
Solved Threads: 0
I understand how to bit shift and all that, but the thing I don't understand is how you would check just the 4 leftmost bits to see if they are a non-zero bit. I have interpreted non-zero to mean 1, as in 0 or 1 in bits. I'm not sure if this is what it means but that's they way I have interpreted it. Also one way I thought about doing this was:
Since 8 bits equals 1 byte, I bit shifted the hashNumber 4 spaces to the right and that would set the four left spots to zero, then I compared them using | to "00000000", and checked to see if the output was still "00000000" and if it was, then that means the 4 leftmost bits must have all been zero's. Does this sound correct to you? Thanks for the assistance.
Since 8 bits equals 1 byte, I bit shifted the hashNumber 4 spaces to the right and that would set the four left spots to zero, then I compared them using | to "00000000", and checked to see if the output was still "00000000" and if it was, then that means the 4 leftmost bits must have all been zero's. Does this sound correct to you? Thanks for the assistance.
![]() |
Similar Threads
- C code into php (PHP)
- bitwise operations in C (C)
- Image read and operation on it (C)
- bitwise operations and masking (C)
- Bitwise operators (C)
Other Threads in the C Forum
- Previous Thread: need help with pancake sorting
- Next Thread: how to use MFC ?
| Thread Tools | Search this Thread |
#include * adobe ansi array asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list locate looping lowest match matrix meter microsoft number oddnumber opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi





