{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ecse221_as1 - Department of Electrical and Computer...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Department of Electrical and Computer Engineering ECSE-221A Introduction to Computer Engineering I Assignment 1 – Data Representation Assigned: Monday, September 8th, 2003 Due: Monday, September 22, 2003 Assignments box, 6 th floor. Question 1 Computers with 64-bit register sizes are becoming increasingly more visible (e.g. Motorola P5, AMD Opteron, Intel Itanium). Although some “C” compilers support a 64-bit integer type (the aptly named longlong ), few implementations (libraries) have a provision for inputting numbers in the range [0, 2 64 -1]. Write a “C” language function that converts a hexadecimal string in the range [0,ffffffffffffffff] into a 64-bit unsigned integer according to the following prototype: int str2udoublelong (char *string, long *doublelong); Since not all compilers support the longlong datatype, the 64-bit integer will be represented as an array of 2 long integers where doublelong[1] corresponds to the most significant word, and doublelong[0] the least significant word. The function should return 0 if the conversion was successful and –1 otherwise (e.g. the input does not correspond to a valid hex string). You may use any functions in the standard “C” library. Your function should be able to handle variable length strings, e.g., 0xff, 0x123456789abcdef, etc. Validate your function be writing an appropriate test program. Exhaustive testing is not feasible, so you must determine an appropriate set of test cases that can provide reasonable assurance that the function will work correctly over the entire range of inputs. Question 2 Write a “C” language program that inputs a hexadecimal string corresponding to either a single or double precision IEEE floating point number and outputs the corresponding decimal floating point representation. The program has exactly 2 arguments: the first specifying either single or double precision and the second the string that is input to the program. Examples: C\ toieee –s 0x7effffff Single precision interpretation of 0x7effffff is 1.7014117e+038 C\ toieee –s 0xffff Single precision interpretation of 0xffff is 9.1834095e-041
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
C\ toieee –d 0x7fefffffffffffff Double precision interpretation of 0x7effffffffffffff is 1.797693134862316e+308 Your program should generate appropriate error messages if the input string does not correspond to a valid hexadecimal number of if the options presented to the program are incorrect. It is also important that your results be displayed to appropriate precision given the respective mantissa sizes.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern