1
$\begingroup$

Find all values of $ x ∈ R $ such that x + 1 = 1 in floating point arithmetic with 3 bits mantissa.

How do we represent number 1 in floating point arithmetic with 3 bits mantissa I wonder? After that, I think we can subtract 1 on both side? I am a little confused about representations of numbers in floating point arithmetic with a specific number of bits in mantissa.

$\endgroup$
4
  • $\begingroup$ There are many conventions that the problem should specify, but a common way to represent $1$ is to not store the $1$ itself and represent it as $000$. Here those zeros are the three digits after the decimal point in $1.000$. No, don't subtract, since floating point arithmetic is not associative. Do they say what is the base, what is the range of exponents? Do they allow denormal numbers? $\endgroup$
    – plop
    Commented Apr 19, 2021 at 20:32
  • $\begingroup$ @plop Thank you very much for your response. I don't think they specified any of those. Let's use the base of 2, 1 bit for sign, 4 bits for exponents (exponent + 7) and 3 bits for mantissa. We may use denormal numbers? Can you help explain this problem? Much appreciation. $\endgroup$
    – Hung Do
    Commented Apr 19, 2021 at 20:36
  • $\begingroup$ See how you add $1.000$ to some other floating point number. You have to sift that other number to fixed point (imagine arbitrary precision), then add it to $1.000$, then bring the result to floating point and finally round. By the way they should also tell you the rounding convention that they are going to apply. So, if at the end the result is again $1$, it means that the rounding cut off any new digits. So, they must be after the three zeros after the decimal point. So, numbers like $1.a_1a_2a_3\times 2^{k}$, with $k\leq -4$ and also the number $0$. $\endgroup$
    – plop
    Commented Apr 19, 2021 at 20:47
  • $\begingroup$ Thank you very much for the helpful insights @plop. I understand the problem much more clearly now. $\endgroup$
    – Hung Do
    Commented Apr 19, 2021 at 22:13

1 Answer 1

1
$\begingroup$

The problem is underspecified, but I'll assume IEEE 754 default behavior.

In IEEE 754, at least in space-constrained floating-point formats, a bit is saved by not storing the leading bit of the mantissa, which is always 1. So the representation of the number 1 would have 000 in the three mantissa bits.

The next largest representable number is 1.001 in binary (001 in the mantissa bits). The next smallest representable number I'll leave for you to figure out (it's not 0.111).

In IEEE 754, addition works by calculating the exact sum of the addends over the reals (infinite precision), then rounding to a representable floating-point number. In the default mode (round to even), you round to the nearest representable value, or if you're exactly halfway between representable values, the tie is broken in favor of the one with 0 in the least significant mantissa bit.

If $a$ is the next smallest representable number below 1, and $b$ is 1.001, then sums in the interval $\left[\frac{a+1}2, \frac{1+b}2\right]$ will be rounded to 1. (It's closed on both ends because round-to-even breaks the tie in favor of 1.) From there it's easy to answer the question.

$\endgroup$
1
  • $\begingroup$ Thank you and @plop. Thanks to you, I finally understand that this problem mainly has to do with rounding and significant figures. And I agree that this problem is under-specified. One can also say that 1 can be represented as $ (1.00)_{2} x 2^{0} $ in 3-bit mantissa here. $\endgroup$
    – Hung Do
    Commented Apr 19, 2021 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.