Machine-precision numbers are stored internally by a 64-bit pattern encoding the IEEE 754 format. Each bit pattern describes a rational number of the form $\pm m\times 2^{e}$ where $m$ is the mantissa or significand and $e$ is the binary exponent. To see which rational number is encoded in a given machine-precision number, we can set the precision to infinity:
SetPrecision[9.2 - 8, Infinity]
(* 337769972052787/281474976710656 *)
SetPrecision[(9.2 - 8)/1.2, Infinity]
(* 9007199254740987/9007199254740992 *)
The latter number is clearly less than 1.
Digging a bit deeper, things clarify when we look at the involved numbers in their hexadecimal representations:
SetPrecision[9.2, Infinity] ==
2^-48*FromDigits["9333333333333", 16]
(* True *)
SetPrecision[9.2 - 8, Infinity] ==
2^-48*FromDigits["1333333333333", 16]
(* True *)
SetPrecision[1.2, Infinity] ==
2^-52*FromDigits["13333333333333", 16]
(* True *)
Note that the representation of 9.2 - 8
has one fewer digits in the periodic expansion than the representation of 1.2
. This comes from the cancellation and error amplification when subtracting two large numbers (here, 9.2 and 8) to form a smaller number (here, 1.2).
Another way of seeing IEEE 754 floating-point numbers is as intervals: for example, the machine-precision number 9.2
is actually the interval of size $2^{-48}$ centered at $2589569785738035\times2^{-48}$: it is $9.2=(2589569785738035\times2^{-48})\pm2^{-49}$. The interval's size is given by the number of binary digits that we can store in the mantissa. Subtracting 8 (an exact number) from this number gives $9.2-8=(337769972052787\times2^{-48})\pm2^{-49}$; notice that the interval's size has not changed. This contrasts with the number $1.2$, which can be expressed as the interval $1.2=(5404319552844595\times2^{-52})\pm2^{-53}$ and has a 16-fold smaller interval size.
(9.2 - 8)/1.2 // FullForm
. $\endgroup$(9.2 - 8)/1.2 // FullForm
illuminating—Mathematica does this occasionally annoying thing where it rounds numerical output in output cells by default. As to why(9.2 - 8)/1.2
is less than one, I'm not totally sure beyond "implementation details", and that's still worth getting an explanation for. EDIT: I see @CarlWoll beat me to it by 15 seconds... :) $\endgroup$Round[x,0.1]
will do the trick for me :D $\endgroup$