$29
1. Write a C/C++ program to find the internal representation of a given integer (int type). Use your program to answer each of the following.
What is the largest integer (LI) that may be represented (express in hex)?
What is the smallest integer (SI) that may be represented (express in hex)?
Your program should initiate the following dialogue with the user
Program enters:Enter I or LI or SI or Q
User enters I 15
Program enters:………
User enters I -67
Program enters:………
User enters LI
Program enters:………
User enters SI
Program enters:………
User enters Q
2. Write a C/C++ program to find the internal representation of floating point (F) numbers. Express the representation as a string of 8 hex characters. (You may use a program that you find on the internet but you should understand how and why it works.)
Given a decimal number, use the program to obtain its single precision FP representation.
Also use the program to find or verify:
• The largest integer (LI) that may be represented(express in hex).
• The smallest positive (SP) number that may be represented(express in hex).
• The smallest positive integer (SI) x such that x can be exactly represented but x+1 cannot(express in hex).
Your program should initiate the following dialogue with the user
Program enters: Enter F or LI or SP or SI or Q
User enters F 1.5
Program enters: ………
User enters F -9876543
Program enters: ………
User enters LI
Program enters: ………
User enters SP
Program enters: ………
User enters SI
Program enters: ………
User enters Q
Output format(for both questions):
• Regardless of endianness, you should convert the representation so that the LS byte appears in the rightmost position.
• For hex string, DO NOT print ‘0x’ at the start. Ex. 0000007C