Intro Matlab Q, floating point system

AI Thread Summary
The discussion revolves around plotting normalized floating point numbers in MATLAB, specifically for a system defined by base b=2, precision p=3, and boundaries L=-2 and U=2. Participants clarify that the equation for calculating these numbers involves binary digits and an exponent, leading to a total of 80 possible values. There is confusion about whether the first mantissa digit is implied, which affects the total count of unique numbers. Suggestions include using MATLAB to create a one-dimensional array for plotting, while also emphasizing the need for clarification from the instructor regarding the problem's specifics. The conversation highlights the importance of understanding the structure of floating point representation in binary systems.
Laura1321412
Messages
23
Reaction score
0

Homework Statement



So this should probably be easy, but for some reason I just can't seem to understand matlab, AT ALL. Anywho,

Consider a normalized floating point number system with b=2 p=3 L=-2 and U=2 , plot all the numbers in this system in a horizontal line, and observe... lalala

Homework Equations





The Attempt at a Solution



I can't not figure out how plot the system! I can't figure out how to enter the system! I undestant floating point numbers, but i just need a hint or two to get started at this question. thankss
 
Physics news on Phys.org
First, eliminate the MATLAB component of your problem and use MS Excel (or equivalent) to do the plot.
 
Laura1321412 said:
Consider a normalized floating point number system with b=2 p=3 L=-2 and U=2
What do these numbers represent?
 
I can't elimate matlab, i am required to use matlab.

b= base = 2, p = precision L and U are the boundaries of value exponent

L<E<U

and the overall equations is

x= +/- (a0 + a1/b + a2/b^2)*b^E

So i need to find all the x for the given equation. But do it using matlab...
 
All told, there are only 80 numbers. Do you know how to find them?

Once you have them, I think that plotting them means drawing a symbol for each of them on the number line.
 
I need to find them using a function i belive... but i can't determine that function i always get matrix errors...
 
Forget MATLAB for the time being. Can you list the 80 numbers I referred to on a piece of paper? I'm trying to figure out how much of this problem you understand.
 
Keep in mind that since the base is 2, the only numbers you can have for a0, a1, and a2 are 0 and 1.
 
Laura1321412 said:
I can't elimate matlab, i am required to use matlab.

b= base = 2, p = precision L and U are the boundaries of value exponent

L<E<U

I'm pretty sure that should be L \le E \le U

and the overall equations is

x= +/- (a0 + a1/b + a2/b^2)*b^E

I thought "normalized" floating point numbers all used an implied "1" (binary, b-1 in general) as the most significant bit of the mantissa.

So shouldn't that be more like ([b-1] + a0/b + a1/b^2 + a2/b^3)*b^EBTW. Does "p" include the implied mantissa digit or not? I mean are there three mantissa digits plus one implied, or is it two plus one implied? (I'm not sure about this).
 
Last edited:
  • #10
My guess is that this exercise doesn't use the implied first mantissa digit. Hopefully the OP will make that clear.
 
  • #11
Hi, yes, i understand the question pretty well i think

I know that the aj will be 0 or 1, and I thought binary then indicated that, Ao = 1?

So wouldn't it be x= +/- ( 1 + A1 / 2 + A2 /4 ) 2 ^ E ?

wouldn't that mean there would be 2*2*2*5 = 40 solns?

Additionally, I think I can solve for the values of X, one at a time, but in MATLAB I was trying do it using matricies... ie )

z [ -1, 1 ]
A1 [ 0,1]
A2 [ 0, 1]
E [ -2, 1,0,1,2,]

and so on. But i think its pretty clear that this won't work, since i need a way to have it work out all the options... Do i need to make more elaborate matricies? Is there a way to do this simply?

Sorry for the lack of elaboration in the OP
 
  • #12
I think you need to get some clarification on this problem from your instructor, about whether the first digit (to the left of the "binary" point) is an implied 1. If so, then each mantissa would look like
\pm 1.a_0a_1a_2 \cdot 2^E

If this is what they look like, then there will be 2 * 8 * 5 numbers in all, because of 8 possibilities of the three binary digits, 5 choices for the exponent, and doubling these because of the sign. That makes 80 numbers in all.

In any case, you can use MATLAB to fill up a single, one-dimension array with all of the numbers.

Next, you need to get clarification on what it means to graph them. My earlier thought was that you could display them all (using, say, an * character) at the right location on an appropriate section of the number line. Does the problem statement give any more guidance on what is needed here? If not, check with your instructor.
 
  • #13
why can't i use something like this on matlab?

for a=0:1
for c=0:1
for w=-1:1
for E=-2:2
x=w.*(1+ (a/2)+(c/4)).*2.^E
end
 
  • #14
I don't know - try it and see. In any case, I believe that there should be three binary digits, not two, as you show.
 
Back
Top