Intro Matlab Q, floating point system

1. Sep 16, 2011

Laura1321412

1. The problem statement, all variables and given/known data

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

2. Relevant equations

3. 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

2. Sep 16, 2011

lewando

First, eliminate the MATLAB component of your problem and use MS Excel (or equivalent) to do the plot.

3. Sep 16, 2011

Staff: Mentor

What do these numbers represent?

4. Sep 16, 2011

Laura1321412

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...

5. Sep 16, 2011

Staff: Mentor

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.

6. Sep 16, 2011

Laura1321412

I need to find them using a function i belive.... but i can't determine that function i always get matrix errors...

7. Sep 16, 2011

Staff: Mentor

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.

8. Sep 16, 2011

Staff: Mentor

Keep in mind that since the base is 2, the only numbers you can have for a0, a1, and a2 are 0 and 1.

9. Sep 17, 2011

uart

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

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^E

BTW. 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: Sep 17, 2011
10. Sep 17, 2011

Staff: Mentor

My guess is that this exercise doesn't use the implied first mantissa digit. Hopefully the OP will make that clear.

11. Sep 17, 2011

Laura1321412

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 wouldnt 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. Sep 17, 2011

Staff: Mentor

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. Sep 17, 2011

Laura1321412

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. Sep 17, 2011

Staff: Mentor

I dunno - try it and see. In any case, I believe that there should be three binary digits, not two, as you show.