[Date Index] [Thread Index] [Author Index]
Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
In article <dra3g3$m55$1 at smc.vnet.net>, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > A partial explanation is given in the documentation for Equal: > > "Approximate numbers are considered equal if they differ in at most > their last eight binary digits (roughly their last two decimal digits)." There is a subtlety here: clearly RealDigits[1.101`2, 2] and RealDigits[1`2, 2] do differ in their "last eight" binary digits (actually, in both cases there are only seven binary digits). The sublety is that all following (suppressed) binary digits are 0. > The workaround is never to set anything to have so few digits of > precision; there is no reason at all to do so. Mathematica's > "significance" arithmetic is an approximation to true interval > arithmetic that works well only at high precision. But if the application is fixed precision arithmetic then one could use RealDigits (in base 2 or 10). For example, RealDigits[1.101`2, 2] == RealDigits[1`2, 2] RealDigits[1.101`2] == RealDigits[1`2] > If you only wanted to reduce the number of digits displayed you > should use > > NumberForm[1.101, 2] Or set the PrintPrecision options using the Option Inspector. Cheers, Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul