Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EXERCISE THREE: Addition in Base 2 1 . Write a function z = AddIntegral ( x , y ) which takes as input two vectors

EXERCISE THREE: Addition in Base 2
1. Write a function z = AddIntegral (x,y) which takes as input two vectors x and y representing two positive integers in base 2 and adds them. It returns the sum z, which is also a vector in base 2. Example: For x =[100111] and y =[1111], your function should return z =[110110]
2. Write a function [IF]= AddFractional (x,y) which takes as input two vectors x and y representing two fractional parts in base 2 and adds them. The result might have an integral part I which is not zero. The function therefore returns two vectors: the integral part I of the sum and its fractional part F, both in base 2.
Example: For x =[1111] and y =[111], your function should return: I =1 and F =[1101]
3. Write a function [IF]= AddBinary (Ix, Fx, Iy, Fy) which will operate on two
fractional binary numbers x and y whose integral parts are the binary vectors Ix and Iy
respectively, and their fractional parts are the binary vectors Fx and Fy respectively.
It returns [I F], which are two vectors containing respectively the integral and the
fractional part of the sum of x and y. Example: For Ix =[100111], Iy =[1111], Fx =[1111], and Fy =[111], your function should return: I =[110111] and F =[1101]
4. Write a function [IFE]= main(Fx, Fy), which will operate on two positive numbers x and y in IEEE single precision assuming integral parts equal to 1 and an exponent equal to zero. It takes as input Fx and Fy, which are respectively the fractional parts of x and y, in the IEEE single representation. It returns [IFE], which are 3 vectors containing respectively the integral, the fractional part, and the exponent of the sum of x and y, in a normalized format and rounded to the closest in the IEEE single precision representation. Example: For Fy =[11111111111111111111111] and
Fx =[00000000000000000000001] your function should return: I =1, F =[100000000000000] and E =1

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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions