The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point

Post by answerhappygod »

The Purpose Of This Assignment Is To Become More Familiar With Bit Level Representations Of Integers And Floating Point 1
The Purpose Of This Assignment Is To Become More Familiar With Bit Level Representations Of Integers And Floating Point 1 (131.65 KiB) Viewed 38 times
can you write with C thanks
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 C or Java programming language; that takes a file containing numbers • the byte ordering type (Little Endian or Big Endian), • the size of the floating point data type (the size of both signed and unsigned integers are 2 bytes), as input and converts the contents of the file to hexadecimal according to the predefined format and gives the converted data as output. The data type can be any of the following: • signed integer • unsigned integer • floating point number The size of the data type can be 1, 2, 3 or 4 bytes • The signed integers are written as normal integers in the file (e.g., 3, -5, etc.). • The unsigned integers are written as integers followed by the letter u (e.g., 3u, 5u, etc.). • The floating point numbers are written with a decimal point (e.g., 3.0, -5.987, etc.). • If the read data type is signed integer, your program will convert the numbers in the input file using 2's complement representation. • If the read data type is unsigned integer, numbers will be converted using unsigned integer representation. • If the read 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: o if 1 byte (i.e., 8 bits), 3 bits will be used for exponent part o if 2 bytes (i.e., 16 bits), 8 bits will be used for exponent part o if 3 bytes (i.e., 24 bits), 10 bits will be used for exponent part o if 4 bytes (i.e., 32 bits), 12 bits will be used for exponent part o While calculating the mantissa to get the floating point value, you will only use the first 13 bits of the fraction part. 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 file. • The format of the input file will be like the following:
o in the input file, each line will include a single number. Example: input.txt 29.109375 4u -9 6u 0 -63.0 • After a valid input file is taken as input, the user will be prompted for the byte ordering type and size: Example: Byte ordering: Floating point size: 2 0 0 - You program will calculate the hexadecimal value of the file content with the given information: Example: The byte ordering is Little Endian, and the floating point is 2 byte. O First, your program will read the first number of the file. For our "input.txt" the first number is: 29.109375 o This is a floating point number. 29.109375 = 11101.000111 = 1.1101000111 * 2* Mantissa is 1.1101000111. However, for 2 bytes we ave 7 bits of fraction part, so we need to round it. 1.1101000111 = 1.1101001. The fraction part is 1101001. E = 4. Exponent is E = exp - Bias, were Bias = 28-1-1 = 127. Therefor te equation is 4 = exp - 127. exp = 131 which is 10000011. The number is positive, so the sign bit is 0. o The number at total is 0100000111101001 which is 0x41E9 in hexadecimal. o Byte ordering is little endian, so the floatig point is represented as E9 41. So the first line of the output line has to be E9 41. Example 2: oIf the program reads the following number: 4u This is an unsigned integer. Unsigned integers are 2 bytes: 4 = 0000000000000100 00000000000000100 is 0x0004 in hexadecimal. o The byte ordering is little endian, so the unsigned integer will be represented as 04 00. 0 You cannot use library functions for the binary to decimal conversions.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply