GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Dec-2005, 19:27
Shrikharan Shrikharan is offline
New Member
 
Join Date: Dec 2005
Posts: 5
Shrikharan is on a distinguished road

What practical use of Bits and Hexadecimal for C programmer?


I am new to C programming, but I have come a long way though .

Can someone explain as to how does the knowledge of bit manipulation and hexadecimal knowledge come to use in C programming. I know computers work in binary form but does a C programmer really have to know the binary and hexadecimal format? Where is a C programmer use them?

As an analogy, it is similar to that even though the computers work at very low level assembly language form the programmer does not need to know assembly language to get by and not knowing assembly language does not make a C programmer handicapped in any way.

Thanks in advance

Shrikharan
  #2  
Old 26-Dec-2005, 22:29
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: What practical use of Bits and Hexadecimal for C programmer?


Bit Manipulation is important because There are many cases where you need to look at specific bits in a word, or to save space you use a 32 bit word to store the values of flags (on/off values) instead of 32 words, one for each flag.

Or consider that wooden puzzle with 21 holes in a triangle shape, 20 golf tees are placed in the holes leaving one open. The puzzle is solved by jumping tees until only one is left. If you want to program a solution to this puzzle in the smallest space you will need either
1) 2 dimensional array of 20 x 21 words (20 moves, 21 holes), each word representing a hole either with or without a tee. 420 words, 13440 bits
2) 1 dimensional array of 20 words, 21 bits of of each word represents a hole. Total of 20 words, 640 bits.

With bit manipulation you can deal with each bit individually.
--------------------

Hex is also extremely important to understand. It makes the bit manipulation much easier to debug/test as well as many other benefits. For now you can just take my word for it. Once you learn hex you'll understand why...
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problems typecasting an int to a string holbrook C++ Forum 9 07-May-2004 19:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:56.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.