[Numpy-discussion] Floating point question

Robert Kern robert.kern@gmail....
Mon Mar 2 14:59:43 CST 2009


On Mon, Mar 2, 2009 at 15:00, Michael S. Gilbert
<michael.s.gilbert@gmail.com> wrote:
> On Mon, 2 Mar 2009 15:37:33 -0500, Gideon Simpson wrote:
>> My two questions are:
>>
>> 1.  What is the best way to handle this?  Is it just to add a filter
>> of the form
>>
>>       u = u * ( np.abs(u) > 2.3 e-308)
>>
>> 2.  What gives?  What's the origin of this (perceived) inconsistency
>> in floating points across languages within the same platform?
>
> how are you calculating fmin?  numpy has a built-in function that
> will tell you this information:
>
>>>> numpy.finfo( numpy.float ).min
> -1.7976931348623157e+308
>
> hopefully this helps shed some light on your questions.

That's the most-negative representable float, but it is not the
smallest-positive (normalized) float (.tiny), which is what he needs
to work with.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list