Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the function decimal2binary, can a computer tell the numbers 1.23456 and 1.2345 apart if bfloat16 numbers are used? function [m,p,r] = decimal2binary(x,N) %Input %x:
Using the function decimal2binary, can a computer tell the numbers 1.23456 and 1.2345 apart if bfloat16 numbers are used?
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; x = x-2^n;
for i = 1:N n = p-i; if 2^n <= x m(i) = 1; x = x-2^n; end end
r = x;
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started