# Need help for a beginner to floating-point arithmetic

I have this question that I need to complete and I literally have zero idea on what to do. I basically need someone to talk me through it and will appreciate all the help I can get.

The question states:

Consider a "toy system" of floating-point arithmetic such that every number is of the form:

$x=(-1)^s * (1+m) * 2^{e - \delta}$

The mantissa $0 ≤ m < 1$ is a number whose binary representation is of the form:

$m=0 . m_1 m_2 m_3$ (base 2)

Where $m_1$, $m_2$, $m_3$ are either $0$ or $1$. Also, $s$ is either $0$ to $1$. The exponent $e$ is an integer such that $1 ≤ e ≤ 6$ and $\delta = 3$ is the shift.

1. What is the largest positive number?
2. What is the smallest positive number?
3. What is the machine epsilon?
4. List all the possible values the mantissa can take.
5. How many floating-point numbers are in this set?

Express all the results as decimal numbers (base $10$).

Now I literally have no idea what this is really on about. So guidance and some help would be really wonderful. Thanks for your time.

• Why not try writing down a few examples, to see what makes such numbers positive or negative, larger or smaller, and how many possibilities in all this representation allows? Oct 21, 2013 at 0:34
• Hi hardmath, thanks for your comment. So if I take the largest value of m which I guess is 0.111 which is 0.875 in base 10 then e as 6. So would 15 be the largest positive number and the smallest positive number would therefore be 0.25? Oct 21, 2013 at 0:43
• I'm confident with converting from base 2 to 10, so if those first 2 are correct, can you help me with 3 and 5 since 4 is just the case of going through 0.000 to 0.111? Oct 21, 2013 at 0:48
• Scrap that, I'm being dumb! I think it's only 3 that I am having problems with. Not sure on what a machine epsilon is and how to work it out. Oct 21, 2013 at 0:50
• @104078: The fact that machine epsilon is 0.25 does not imply that the (binary) values the mantissa can take are limited to multiples of machine epsilon. As the Question itself states, the mantissa can be any binary representation $0.m_1m_2m_3$. It is left to the Readers (doing the exercise) to convert these into decimal representations. Dec 29, 2014 at 16:28

The notion of machine epsilon in floating-point arithmetic is useful in getting upper bounds on the contribution a rounding error can make in a single operation.

The task here is simply applying the definition. Machine epsilon is the smallest machine-representable positive value we can obtain by subtracting $1$ from a floating-point value slightly greater than $1$. Intuitively we are apt to think of this as a "unit in the last place" of mantissas normalized to exponent $0$, but as we will see the range of exponents can affect this.

For reference let's begin with a representation of $1$ in our "toy" binary arithmetic scheme:

$$+(1.000)_2 \times 2^0 = 1.0$$

Note that net exponent is zero, which means (taking the bias $\delta = 3$ into account) that $e = 3$ (and, of course, sign bit $s=0$ since the number $1$ is positive).

The first thing we would think about is the smallest number we can represent which is greater than one, i.e. by setting the mantissa bit $m_3$ from $0$ to $1$. Although we can do that, the resulting number is so close to $1$ that the exact difference (subtracting one) is not machine representable. The exact difference would be one-eighth (or 0.125 decimal), and to represent this in our binary arithmetic scheme would require $e - \delta = -3$, or $e = 0$. The format specification however says $1 \le e \le 6$, so we cannot represent that difference. Presumably in an actual calculation the difference might be rounded down to zero, but we don't have to speculate about how it would be handled.

Rather, just applying the definition, we see that the smallest positive difference that can be represented is one-quarter, corresponding to $e=1$:

$$+(0.010)_2 = +(1.000)_2 \times 2^{1-3}$$

The limitation in the range of (offset) exponents is then a bit of trickery in this problem, giving us machine epsilon of one-quarter or 0.25 decimal.