Click here to Skip to main content
15,899,124 members
Home / Discussions / C#
   

C#

 
QuestionLine Numbers display.... Pin
spalanivel21-Jul-09 0:34
spalanivel21-Jul-09 0:34 
AnswerRe: Line Numbers display.... Pin
Nagy Vilmos21-Jul-09 0:46
professionalNagy Vilmos21-Jul-09 0:46 
QuestionC# MDI Application Pin
sateesh villa20-Jul-09 23:40
sateesh villa20-Jul-09 23:40 
AnswerRe: C# MDI Application Pin
Manas Bhardwaj20-Jul-09 23:45
professionalManas Bhardwaj20-Jul-09 23:45 
GeneralRe: C# MDI Application Pin
sateesh villa21-Jul-09 0:34
sateesh villa21-Jul-09 0:34 
GeneralRe: C# MDI Application Pin
vhassan21-Jul-09 1:00
vhassan21-Jul-09 1:00 
QuestionGet the input values at the time of scrolling... Pin
spalanivel20-Jul-09 23:37
spalanivel20-Jul-09 23:37 
AnswerRe: Get the input values at the time of scrolling... Pin
Nagy Vilmos21-Jul-09 0:41
professionalNagy Vilmos21-Jul-09 0:41 
GeneralRe: Get the input values at the time of scrolling... Pin
spalanivel21-Jul-09 1:30
spalanivel21-Jul-09 1:30 
GeneralRe: Get the input values at the time of scrolling... Pin
Luc Pattyn21-Jul-09 1:55
sitebuilderLuc Pattyn21-Jul-09 1:55 
GeneralRe: Get the input values at the time of scrolling... Pin
Nagy Vilmos21-Jul-09 2:03
professionalNagy Vilmos21-Jul-09 2:03 
GeneralRe: Get the input values at the time of scrolling... Pin
spalanivel21-Jul-09 21:22
spalanivel21-Jul-09 21:22 
GeneralRe: Get the input values at the time of scrolling... Pin
Nagy Vilmos21-Jul-09 23:36
professionalNagy Vilmos21-Jul-09 23:36 
GeneralRe: Get the input values at the time of scrolling... Pin
spalanivel22-Jul-09 1:00
spalanivel22-Jul-09 1:00 
QuestionHow do you find value of bits in byte Pin
gwithey20-Jul-09 23:34
gwithey20-Jul-09 23:34 
AnswerRe: How do you find value of bits in byte Pin
Mirko198020-Jul-09 23:43
Mirko198020-Jul-09 23:43 
GeneralRe: How do you find value of bits in byte Pin
gwithey21-Jul-09 0:30
gwithey21-Jul-09 0:30 
GeneralRe: How do you find value of bits in byte Pin
gwithey21-Jul-09 0:44
gwithey21-Jul-09 0:44 
AnswerRe: How do you find value of bits in byte Pin
monstale20-Jul-09 23:47
monstale20-Jul-09 23:47 
GeneralRe: How do you find value of bits in byte Pin
gwithey21-Jul-09 0:20
gwithey21-Jul-09 0:20 
GeneralRe: How do you find value of bits in byte Pin
monstale21-Jul-09 0:53
monstale21-Jul-09 0:53 
AnswerRe: How do you find value of bits in byte Pin
0x3c020-Jul-09 23:51
0x3c020-Jul-09 23:51 
It's a matter of using ANDs, and other boolean stuff (if you want to read multiple bits). Basically, you use the formula:

bitNSet = (originalInteger & (1 << N) == 1 << N)

Effectively, every integer is represented by a binary sequence. For example, 39 would be represented by 100111. Each one and zero is a bit. To get a bit, you have to AND it, which gets all the bits which are set in both of the numbers given to it. For example, 39 AND 4 would be worked out like so:

100111 AND
000100 =
------
000100

As you can see, you end up with a binary sequence, which is represented by 4 in decimal (base-10). You use the AND against a bit pattern to see if that bit is set. Now, unfortunately, you don't get a true or false value. Note that the result of 39 AND 4 was 4. So, we can apply this further, and say that if q AND n is equal to n, then bit n was set.

Now we just have to get a binary pattern to use against the AND. To get this, we just use the << operator. It will perform a left binary shift on the left operand. So 1 << 5 would result in 100000, 1 << 2 would result in 100, etc. Those numbers are in binary format by the way. So, shifting 1 left by N will give us a binary pattern where only the Nth bit is set. By ANDing that with the original integer, we can check if the bit is set

Between the idea
And the reality
Between the motion
And the act
Falls the Shadow

AnswerRe: How do you find value of bits in byte Pin
DaveyM6921-Jul-09 2:01
professionalDaveyM6921-Jul-09 2:01 
GeneralRe: How do you find value of bits in byte Pin
PIEBALDconsult21-Jul-09 4:18
mvePIEBALDconsult21-Jul-09 4:18 
AnswerRe: How do you find value of bits in byte Pin
Luc Pattyn21-Jul-09 2:05
sitebuilderLuc Pattyn21-Jul-09 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.