Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 2a) As part of the floating point number representation, we need to specify an integer-valued exponent. Internally, the exponent is also represented as a

Python

image text in transcribed

2a) As part of the floating point number representation, we need to specify an integer-valued exponent. Internally, the exponent is also represented as a sequence of binary digits. If a digits are allocated for the exponent, 24 exponent values can be represented. For example, an 8-bit integer can represent 28 = 256 values, and the represented range is often chosen to be {0, 1, ..., 254, 255} for the specification of things like intensity of color channels (e.g. RGB). When working with exponents instead of intensities we are equally interested in positive and negative values (and definitely want to include zero), so the usual convention is to shift the represented value by subtracting 127 to represent the 'symmetric range {-127, -126, ...,-1,0, 1, ..., 127, 128) Write a function below that outputs a 2-tuple of integers corresponding to the minimum and maximum values of the exponents in the symmetric range for a q-bit integer. In (): def sym_bounds (a): compute the min, max values for a symmetric range of a q-bit integer Args: q: number of binary digits Returns: integer 2-tuple of min and max values # YOUR CODE HERE raise Not ImplementedError() return value_range In [ ]: assert_equal(sym_bounds(8), (-127, 128)) 2b) Write a function (by completing the template below) to produce a numpy array containing the sorted gamut of normalized representable positive numbers for a floating point system with 3 binary digits of precision and 3 binary digits for specifying the exponent. Hints: Start by computing the number n of normalized mantissa values described by 3 digits and the symmetric range (Emin, emax) of 3-digit exponents. Create a 10 array of length no and and store the representable values corresponding to exponent e = 0. Create a 10 array of size 24 and store the values of 2 fore in the representable range of exponents. Create a 2D array of size n0 x 29 and use a doubly nested loop to store the product of each mantissa with each exponential. Find numpy functions to flatten and sort the list. In : import numpy as np def pos_gamut3(): compute the representable values for a floating point system Args : NONE Returns: numpy array of normalized positive values for 3 digits and 3-bit exponent # YOUR CODE HERE raise Not ImplementedError() return vals 2c) Compute the gamut for the system and create a plot to illustrate the representable values. In [ ]: # YOUR CODE HERE raise Not ImplementedError()

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions