Re: inconsistency with Inequality testing and Floor

• To: mathgroup at smc.vnet.net
• Subject: [mg60127] Re: inconsistency with Inequality testing and Floor
• From: "Ray Koopman" <koopman at sfu.ca>
• Date: Sat, 3 Sep 2005 02:06:22 -0400 (EDT)
• References: <df944v\$62b\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Bill Rowe wrote:
> I've no idea as to why Mathematica was designed in this manner, but
> generally when I am using machine precision numbers it is to model the real
> world in some way. My knowledge (i.e., measured data) never has sufficient
> precision to argue two numbers within 8 binary bits of each other are
> distinct. So, I much prefer in these cases Mathematica treats them as equal.
>
> However, I can see where this behaviour would cause problems in other
> applications. And for those applications, the solution is to use "==="
> rather than "==",

Not quite. "SameQ" will still give "True" for two machine-precision
reals even though their least significant bits differ.

In[1]:=
Block[{x = 1.+#*\$MachineEpsilon}, {(x-1)/\$MachineEpsilon,
Ceiling[x], x === 1., x > 1., x == 1.}]& /@ {1,2,64,65}

Out[1]=
{{ 1., 2, True,  False, True },
{ 2., 2, False, False, True },
{64., 2, False, False, True },
{65., 2, False, True,  False}}

In[2]:=
Block[{y = 1.-#*\$MachineEpsilon/2}, {(1-y)2/\$MachineEpsilon,
Floor[y], y === 1., y < 1., y == 1.}]& /@ {1,2,127,128}

Out[2]=
{{  1., 0, True,  False, True },
{  2., 0, False, False, True },
{127., 0, False, False, True },
{128., 0, False, True,  False}}

```

• Prev by Date: scaling of ndsolve to large systems
• Next by Date: Would a code generator from dynamic systems be feasible and useful?
• Previous by thread: Re: inconsistency with Inequality testing and Floor
• Next by thread: Re: inconsistency with Inequality testing and Floor