I would like to know if there is a formula or any other way to find out how many bits of difference between two values given the relative error. For instance:

$$\epsilon_{\text{rel}} = \frac{V - V_\text{approx}}{V}$$

so, my relative error for instance could be calculated:

$$\epsilon_{\text{rel}} = \frac{10936907150.600960- 10936907150.600958}{10936907150.600960} = 1.82\times 10^{-16}$$

How can I know how many bits of difference I have here?


That depends on the number of bits in the floating numbers. If you are using 53-Bit IEEE-Double arithmetic, a relative error of $1.82\times 10^{-16}$ means that the error is 1 or 2 bits.

  • $\begingroup$ @_gammatester How do you calculate that? If you convert those values to binary, they are identical, i.e. there is less than 1 bit of difference $\endgroup$ – Manolete Apr 4 '14 at 10:50
  • 1
    $\begingroup$ That depends slightly on the rounding, I just calulated the Hex values with babbage.cs.qc.cuny.edu/IEEE-754.old/Decimal.html and got 1 bit difference. 10936907150.600960 = 42045F1FAC74CEC4 vs. 10936907150.600958 = 42045F1FAC74CEC3. $$ $$The machine epsilon for double is $\epsilon = 2.2204460492503131\times 10^{-16}$, some people $\epsilon/2$ as the unit for the round-off error. $\endgroup$ – gammatester Apr 4 '14 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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