Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Clip[] doesn't work as expected

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115394] Re: Clip[] doesn't work as expected
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Mon, 10 Jan 2011 02:36:02 -0500 (EST)
  • References: <ig6lcm$dpm$1@smc.vnet.net>

I don't think this is a bug. I all depends on the accuracy of the
upper bound, 1.0. Since it is specified as machine precision the
outcome and the upper limit are the same

In[86]:= 1.0 == 1.00000000000001

Out[86]= True

One zero less:

In[87]:= 1.0 == 1.0000000000001

Out[87]= False

Try using the exact number 1 as the upper limit (wihout decimal
point).

In[88]:= Clip[1.00000000000000036, {0., 1}]

Out[88]= 1

Cheers -- Sjoerd

On Jan 7, 10:11 am, Yen Lee Loh <yenleel... at gmail.com> wrote:
> On Mathematica v7.0.1 on Mac OS X,
>
> Clip[1.00000000000000036, {0., 1.}]
>
> gives
>
> 1.0000000000000004
>
> upon close examination of the output.  The documentation does not warn of
> this behavior.
> I have not checked if the same thing happens in Mathematica v8.
> Just thought I would let you know.
>
> Yen Lee



  • Prev by Date: Re: need help with CUDA setup on my MacBook Pro
  • Next by Date: Re: How do I do very big integer computing by Mathematica?
  • Previous by thread: Re: Clip[] doesn't work as expected
  • Next by thread: Re: Clip[] doesn't work as expected