CS Behind the Curtain (CS195 2003S)

Homework 4: From Binary to Decimal and Back Again

Summary: In this assignment, you will futher your understanding of the various binary representations of integers. expressions.

Assigned: Monday, 3 February 2003.

Due: Friday, 7 February 2003.

Collaboration: You may discuss this assignment with anyone you wish. You may implement the work alone, in pairs, or in triplets.

Implementation Language: You must do this assignment in C.

Submitting Your Work: Type your work electronically and submit it via the ECA. If you can't get it to work, email me your source code.

Part One: Binary to Decimal

Write a program, b2d, that reads in a series of eight 0's and 1's, and interprets them as if they were

  1. an unsigned integer;
  2. a signed integer in signed magnitude format;
  3. a signed integer in one's complement format;
  4. a signed integer in two's complement format; and
  5. a signed integer in excess 27 format.

Part Two: Decimal to Binary

Write a program, d2b, that reads an integer in decimal format and prints it out in

  1. 32 bit unsigned binary format (provided it is non-negative);
  2. 32 bit signed magnitude format;
  3. 32 bit one's complement format;
  4. 32 bit two's complement format; and
  5. excess 231 format.

 

History

Sunday, 2 February 2003 [Samuel A. Rebelsky]

 

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Fri May 2 14:19:37 2003.
The source to the document was last modified on Mon Feb 3 13:51:47 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS195/2003S/Homework/hw.04.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu