Re: Next floating point number

2005-12-18 Thread Tim Peters
[Steven D'Aprano] > ... > Will Python always use 64-bit floats? A CPython "float" is whatever the platform C compiler means by "double". The C standard doesn't define the size of a double, so neither does Python define the size of a float. That said, I don't know of any Python platform to date w

Re: Next floating point number

2005-12-18 Thread Tim Peters
[Bengt Richter] > I wonder if frexp is always available, Yes, `frexp` is a standard C89 libm function. Python's `math` doesn't contain any platform-specific functions. ... > The math module could also expose an efficient multiply by a power > of two using FSCALE if the pentium FPU is there. `l

Re: Next floating point number

2005-12-18 Thread Steven D'Aprano
On Sun, 18 Dec 2005 08:37:40 +, Bengt Richter wrote: > On Sun, 18 Dec 2005 10:27:16 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >>On Sat, 17 Dec 2005 09:26:39 +, Bengt Richter wrote: >> >> >>> I wonder if this won't work (for IEEE 754 double that is) >

Re: Next floating point number

2005-12-18 Thread Bengt Richter
On Sun, 18 Dec 2005 10:27:16 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Sat, 17 Dec 2005 09:26:39 +, Bengt Richter wrote: > > >> I wonder if this won't work (for IEEE 754 double that is) ^^^[1] >> >> from math import frexp >> def next

Re: Next floating point number

2005-12-17 Thread Steven D'Aprano
On Sat, 17 Dec 2005 03:27:11 -0500, Tim Peters wrote: > While the C99 standard defines such a function (several, actually), > the C89 standard does not, so Python can't rely on one being > available. In general, Python's `math` module exposes only standard > C89 libm functions, plus a few extras

Re: Next floating point number

2005-12-17 Thread Steven D'Aprano
On Sat, 17 Dec 2005 09:26:39 +, Bengt Richter wrote: > I wonder if this won't work (for IEEE 754 double that is) > > from math import frexp > def nextf(x, y): > f,e = frexp(x) > if (f==0.5 or f==-0.5) and x>=y: eps = 2.0**-54 > else: eps = 2.0**-53 > if x else: return (f-

Re: Next floating point number

2005-12-17 Thread Bengt Richter
On Sat, 17 Dec 2005 14:23:38 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >I'm looking for some way to get the next floating point number after any >particular float. > >(Any mathematicians out there: I am aware that there is no "next real >number". B

Re: Next floating point number

2005-12-17 Thread Tim Peters
[Steven D'Aprano] > I'm looking for some way to get the next floating point number after any > particular float. ... > According to the IEEE standard, there should be a routine like next(x,y) > which returns the next float starting from x in the direction of y. > > Un

Re: Next floating point number

2005-12-16 Thread Robert Kern
Steven D'Aprano wrote: > Unless I have missed something, Python doesn't appear to give an interface > to the C library's next float function. I assume that most C floating > point libraries will have such a function. http://www.mkssoftware.com/docs/man3/nextafter.3.asp -- Robert Kern [EMAIL PRO

Next floating point number

2005-12-16 Thread Steven D'Aprano
I'm looking for some way to get the next floating point number after any particular float. (Any mathematicians out there: I am aware that there is no "next real number". But floats are not real numbers, they only have a finite precision.) According to the IEEE standard, there shou