Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the minimum number for N to calculate the value of ln x for x = 4.5 exactly as a half precision number? Use

What is the minimum number for N to calculate the value of ln x for x = 4.5 exactly as a half precision number? Use the function decimal2binary to answer this question.

MY FUNCTION

function [m,p,r] = decimal2binary(x,N)

%Input %x: decimal number to translate %N: number of mantissa bits to use. %output %m:vector of N mantissa bits %p: decimal exponent of the binary floating number %r: remainder

m = zeros(N,1); p = floor(log(x)/log(2));

n = p;

%calculate the remainder x taking the hidden bit into account x = x-2^n;

%loop over all requested mantissa bits for i = 1:N n = p-i; %working exponent of the i-th bit if 2^n <= x m(i) = 1; %set bit to 1 x = x-2^n; % update the remainder end end

%remainder r = x;

end

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions