Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a unique code. The purpose of this assignment is to become more familiar with bit-level representations of integers and floating-point numbers. In this

image text in transcribedimage text in transcribedimage text in transcribed

Please write a unique code.

The purpose of this assignment is to become more familiar with bit-level representations of integers and floating-point numbers. In this project, you will implement an application, in Java or Python programming language: that takes a hexadecimal number and the data type to be converted, as input and converts the number according to the predefined format and gives the converted data as output. The data type can be any of the following: signed integer (5) unsigned integer (U) floating point number (F) The size of the input can be 1, 2, 3 and 4 bytes, if input is other than these sizes then an error message will be given. If the selected data type is signed integer, your program will convert the number using 2's complement representation If the selected data type is unsigned integer, number will be converted using unsigned integer representation. . If the selected data type is floating point number, you will use IEEE-like format. The number of exponent bits according to given data size will be like the following: if 1 byte (.e., 8 bits). 4 bits will be used for exponent part if 2 bytes (i.e., 16 bits). 6 bits will be used for exponent part if 3 bytes (i.c., 24 bits). 8 bits will be used for exponent part if 4 bytes (i.e., 32 bits), 10 bits will be used for exponent part - For each given data size 1 bit will be used for sign and remaining bits will be used for fraction - While calculating the mantissa to get the floating-point value, you will only use the first 13 bits of the fraction part (If the data size is 3 or 4 bytes). You will use "round to even" method for rounding fraction bits to 13 bits. Details about the program are listed below: At the beginning of the execution, your program will prompt for the input. If the input has odd number of characters complete it to even by adding O to the MSB. - For example: If the number entered is A57, it will be stored as 0457 and its size is 2 bytes. If the number is 12345, it will be stored as 012345, and its size is 3 bytes. . If the input is 123456789, then an error message is given. (bigger than 4 byte) . Any inappropriate input results an error message. (Only digits and characters from A to F will be accepted as an input) After a valid input is taken, the user will be prompted for the data type: Example: Data type: F . And then your program will calculate the decimal value of input with the given information: Example 1: Enter the number: 4001 90F0 Datatype: F Floating point number is: 40 01 90 to, in binary: 0100 0000 0000 0001 1001 0000 1111 0000 . In the specification, we are given that our 4 byte IEEE-like floating point numbers have 10 bits of exponent part, so Bias24.1 511: Signbito Exponent (1000000000 = 512 Fraction=00001100100001 1110000 rounded fraction = 0000110010001 mantissa = 1+1/32-1/64+1/312+1/8192 = 1.0489501953125 Decimal value = (-10 * 1.0489501953125 25-011 2.097900390625 The printed value will be: 2.09790 Example 2: If the input: Enter the number: 801 80000 beta type: F Floating point number is: 80 18 00 00, in binary: 1000 0000 0001 1000 0000 0000 0000 0000 - In the specification, we are given that our 4 byte IEEE-like floating point numbers have 10 bits of exponent part, so Bits 2-1 = 511: Sign bit = 1 Exponent=0000000000 denormalized number Fraction = 110000000000000000000 rounded fraction = 1100000000000 mantissa = 0+1/2+1/4 = 0.75 Decimal value = (-1)3 +0.75 91-111 = -2.237302222-154 The printed value will be:-2.237506-154 Example : Enter the number: 83A Datatypes Floating point number is 08 3A, in binary: 0000 1000 0011 1010 It is positive binary number and it will be directly converted to decimal The printed value will be : 2106 Floating point numbers may be NaN, +0 -0 or infinity. In these cases, the output will be NaN 00 For the output, the floating-point numbers will have precision of maximum 5 digits after the decimal point. You cannot use library functions for the binary to decimal conversions. The purpose of this assignment is to become more familiar with bit-level representations of integers and floating-point numbers. In this project, you will implement an application, in Java or Python programming language: that takes a hexadecimal number and the data type to be converted, as input and converts the number according to the predefined format and gives the converted data as output. The data type can be any of the following: signed integer (5) unsigned integer (U) floating point number (F) The size of the input can be 1, 2, 3 and 4 bytes, if input is other than these sizes then an error message will be given. If the selected data type is signed integer, your program will convert the number using 2's complement representation If the selected data type is unsigned integer, number will be converted using unsigned integer representation. . If the selected data type is floating point number, you will use IEEE-like format. The number of exponent bits according to given data size will be like the following: if 1 byte (.e., 8 bits). 4 bits will be used for exponent part if 2 bytes (i.e., 16 bits). 6 bits will be used for exponent part if 3 bytes (i.c., 24 bits). 8 bits will be used for exponent part if 4 bytes (i.e., 32 bits), 10 bits will be used for exponent part - For each given data size 1 bit will be used for sign and remaining bits will be used for fraction - While calculating the mantissa to get the floating-point value, you will only use the first 13 bits of the fraction part (If the data size is 3 or 4 bytes). You will use "round to even" method for rounding fraction bits to 13 bits. Details about the program are listed below: At the beginning of the execution, your program will prompt for the input. If the input has odd number of characters complete it to even by adding O to the MSB. - For example: If the number entered is A57, it will be stored as 0457 and its size is 2 bytes. If the number is 12345, it will be stored as 012345, and its size is 3 bytes. . If the input is 123456789, then an error message is given. (bigger than 4 byte) . Any inappropriate input results an error message. (Only digits and characters from A to F will be accepted as an input) After a valid input is taken, the user will be prompted for the data type: Example: Data type: F . And then your program will calculate the decimal value of input with the given information: Example 1: Enter the number: 4001 90F0 Datatype: F Floating point number is: 40 01 90 to, in binary: 0100 0000 0000 0001 1001 0000 1111 0000 . In the specification, we are given that our 4 byte IEEE-like floating point numbers have 10 bits of exponent part, so Bias24.1 511: Signbito Exponent (1000000000 = 512 Fraction=00001100100001 1110000 rounded fraction = 0000110010001 mantissa = 1+1/32-1/64+1/312+1/8192 = 1.0489501953125 Decimal value = (-10 * 1.0489501953125 25-011 2.097900390625 The printed value will be: 2.09790 Example 2: If the input: Enter the number: 801 80000 beta type: F Floating point number is: 80 18 00 00, in binary: 1000 0000 0001 1000 0000 0000 0000 0000 - In the specification, we are given that our 4 byte IEEE-like floating point numbers have 10 bits of exponent part, so Bits 2-1 = 511: Sign bit = 1 Exponent=0000000000 denormalized number Fraction = 110000000000000000000 rounded fraction = 1100000000000 mantissa = 0+1/2+1/4 = 0.75 Decimal value = (-1)3 +0.75 91-111 = -2.237302222-154 The printed value will be:-2.237506-154 Example : Enter the number: 83A Datatypes Floating point number is 08 3A, in binary: 0000 1000 0011 1010 It is positive binary number and it will be directly converted to decimal The printed value will be : 2106 Floating point numbers may be NaN, +0 -0 or infinity. In these cases, the output will be NaN 00 For the output, the floating-point numbers will have precision of maximum 5 digits after the decimal point. You cannot use library functions for the binary to decimal conversions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago