1
$\begingroup$

What's the largest number $n$ such that $n!$ can be represented exactly in a floating point system of binary base, mantissa of $24$ digits and an exponent range in $[-100,100]$?

So, my answer is that, the largest number in this system will be

$$x=(1-2^{-24}) \cdot 2^{100} \approx 1.2677\cdot10^{30} $$

Now, since $29! \approx 8.8418\cdot 10^{30}$, and $28! \approx 30489\cdot 10^{29}$, the number $28$ it's the number i'm looking for.

But then, my teacher says that you can only represent integers exactly until $2^{24}$, and just some of the integers between $2^{24}$ and $2^{100}$.

What should it be the correct argument?

$\endgroup$
1
  • $\begingroup$ You certainly can go higher than $2^{24}$ but you will then lose too much precision. So much that the integers themselves cannot uniquely be represented anymore. Therefore above $2^{24}$ you won't be able to distinguish between say $13!$ and $13! + 1$. $\endgroup$
    – Zubzub
    Apr 5, 2017 at 13:11

1 Answer 1

4
$\begingroup$

Your teacher is right, but the answer is subtle.

Integers larger than $2^{24}$ can be represented exactly with 24 bits provided they are of the form $m \cdot 2^e$ with $m < 2^{24}$ and $e$ small.

Indeed, although $11! > 2^{24}$, we still can represent $13!$ exactly because $13! = 6081075 \cdot 2^{10}$ and $6081075 < 2^{24}$.

We cannot represent $14!$ exactly because $14!=42567525 \cdot 2^{11}$ and $42567525 > 2^{24}$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .