MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Reals and Equal

  • To: mathgroup at
  • Subject: [mg62013] Reals and Equal
  • From: dh <dh at>
  • Date: Wed, 9 Nov 2005 03:45:27 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Comparing real numbers can give you considerable headache if you do not 
exactly know how it works.

The Help says:
"Approximate numbers are considered equal if they differ in at most 
their last eight binary digits (roughly their last two decimal digits)"
This is not quit right, as you can convince yourself:

(my Mathematica version: 5.1 for Microsoft Windows (October 25, 2004))

(a+b)== a
gives True

b=1/2^47 + 1/2^53;
(a+b)== a
gives False

that is, if two reals differ  only in the 7th last bit, they are 
considered equal (and e.g. "<" gives False). However, if in addition the 
last bit also differs, they are considers not-equal.

Can anybody give a reason for this strange behaviour.

sincerely, Daniel

  • Prev by Date: Re: integer solution
  • Next by Date: Re: Re: Re: Use of Mathematica with Rule-based Equation Derivations
  • Previous by thread: Re: Re: ((a&&b)||c)==((a||c)&&(b||c))
  • Next by thread: Re: Reals and Equal