- Number bases: decimal, binary, hexadecimal
- Signed number representations: signed magnitude, ones' complement, two's complement
- Review Make School's slides on number bases
- Read BetterExplained's article on number systems and bases
- Read Vaidehi Joshi's articles on binary and hexadecimal with beautiful drawings and excellent examples
- Play with Dan Wolff's live-updating base conversion calculator
- Review Wikipedia's comparison table of signed number representations
- Print and make a Flippy Do binary converter following Code.org's instructions
- Watch Harvard's hexadecimal video
- Watch Corey Schafer's understanding bases video
- Watch Tech Quickie's numbers and base systems video
- Practice binary and hexadecimal conversions on number bases worksheet
- Implement base conversion functions for unsigned numbers using starter code:
- Implement
decode
- decode digits in any base to a number - Implement
encode
- encode a number to digits in any base - Implement
convert
- convert digits in any base to digits in any base - Run
python bases.py number base1 base2
to testconvert
onnumber
- Example:
python bases.py 42 10 2
should give the result101010
- Example:
- Run
pytest bases_test.py
to run the unit tests and fix any failures
- Implement
- Write additional unit tests to ensure your conversion algorithms are robust
- Implement base conversion for fractional numbers using a radix point (try playing with the base conversion calculator to see how this works)
- Implement base conversion for negative binary numbers (using two's complement)