Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here, you will be using the expertise you have recently acquired to represent integers in twos complement form-the way the computer stores them and does

image text in transcribed

Here, you will be using the expertise you have recently acquired to represent integers in twos complement form-the way the computer stores them and does arithmetic with them-and floating point numbers. In particular, you will be writing a C program that will do the following: Function ReadNos()-Read numbers from a text file There will be three files: the first file will contain decimal integers (cp2_lint.txt), the second will contain decimal floating point numbers (cp2_dfloat txt). and the third will contain integers in binary, or base 2 (cp2_2int.txt). Note numbers can be positive or negative Numbers will be separated by white spaces and an end of file (EOF) will end the numbers. 2) Function ConvertDecimal2Binary()-After reading in a decimal number, the program must convert it into the appropriate binary form For a decimal integer, it is to be converted into its 32 bit (signed) twos complement representation. For an integer provided in 32 bit signed twos complement form, it is to be converted into its decimal representation. For a floating point number, it is to be converted into the single precision IEEE floating point format (see e.g. https://en wikipedia org/wiki'Single-precision_floating-point_format). You will write two separate functions, one for converting integers Function ConvertDecInt2Binary() and another function ConvertDecFloat2Binary()for converting floating point numbers These functions will be called by ConvertDecimal2Binary(). Function ConvertBinary2DecInt() This function will convert binary numbers to decimal integers. Function WriteNos()-All numbers converted wall be output into a file using this function A sample output is provided in cp2.out txt You may use this file in developing and testing your program Note that we do insist on splitting the floating point to binary converted output into three parts separated by a space; sign. exponent, and mantissa. as shown in the sample output file cp2.out.txt. so as to make your output easily readable to us Note that when we execute your program it will be with a different file with the same name, and it will contain different numbers altogether

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

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

Students also viewed these Databases questions

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago