Followers

My Visual Studio Achievements

Twitter

Tuesday, February 4, 2014

Below is one program written to demonstrate bit processing to one of the fresh programmer. He was trying to code a simple game where the user guess a number between 1-15 and selects whether the guessed number is present in the groups of numbers shown to him. There will be 4 groups of numbers shown to him.

The program internally shows the numbers which have particular bit positions set. He was doing a big chunk of combinational if statements to decide what is the number guessed based on his selections. This program simplifies it. See the method GetNumberFromBits(). It doesn't cover failure scenarios such as handling a sequence which is more than the size of integer etc..Also all the methods are static.

Seems now a days colleges are not paying attention towards the basics of computer programming which is assembly language which plays with bits.