Next floating point number

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sun Dec 18 07:54:06 EST 2005


On Sun, 18 Dec 2005 08:37:40 +0000, Bengt Richter wrote:

> On Sun, 18 Dec 2005 10:27:16 +1100, Steven D'Aprano <steve at REMOVETHIScyber.com.au> wrote:
> 
>>On Sat, 17 Dec 2005 09:26:39 +0000, Bengt Richter wrote:
>>
>>
>>> I wonder if this won't work (for IEEE 754 double that is)
>                                 ^^^^^^^^^^^^^^^^^^^[1]

Ah! I read that, and blanked it out of my mind :-(


> I wonder if frexp is always available, 

I believe so, since it is part of the math module.

[snip]

> I'm a little curious what you are using this for.

Mostly curiosity -- I'm fascinated by numeric programming, but haven't got
the time to really sit down and learn it properly. But periodically I find
time to dabble for a few hours.

At a more practical level, for many numeric algorithms it is useful to
know the machine accuracy (which of course varies over the range of
floats). The machine accuracy at float x is nextfloat(x) - x. That gives
you an idea of how far apart floats are -- differences smaller than that
number are impossible for the algorithm to resolve.


-- 
Steven.




More information about the Python-list mailing list