You are designing an elevator controller for a building with 25 floors. The controller has two inputs: UP and DOWN. It produces an output indicating the floor that the elevator is on. There is no floor 13. What is the minimum number of bits of state in the controller?
Answer: The system has at least five bits of state to represent the 24 floors that the elevator might be on.
Can someone explain how this comes to be?
Asked By : rioforman
Answered By : Tyler StandishMan
Well, as binary typically goes, one bit represents two possible values: 0 and 1. With two bits there are a possible combination of four values: 0, 1, 2, 3 in hex/decimal/octal or 00, 01, 10, 11 in binary. Expand out to three bits you have eight values. 0 to 7 or 000, 001, 010, 011, 100, 101, 110, and 111.
Expand upon this and you'll have your understanding.
For reference (with a nice animation for counting on any base): https://www.mathsisfun.com/binary-number-system.html
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/48475
0 comments:
Post a Comment
Let us know your responses and feedback