Mark Dickinson <dicki...@gmail.com> added the comment:

I'm not opposed to some form of this by any means, but I fear there's some 
bikeshedding to go through, both on the name and the functionality (one 
function with two arguments, or two functions each taking a single argument?).

C 99 prescribes "nextafter" and "nexttoward" (which is pretty much the same as 
"nextafter" if you don't care about the distinction between float, double and 
long double).

IEEE 754, on the other hand, requires instead nextUp and nextDown, which take a 
single argument and move towards +inf or -inf (respectively).

Python's Decimal type has a two-argument next_toward method.

NumPy has nextafter.

Java provides all three of nextUp, nextDown and nextAfter.

For sure implementing nextafter is easiest, since we can just wrap the C 
version. That doesn't *necessarily* make it the right variant to go for.

(Annoyingly enough, none of these is actually what I tend to want in practice, 
which is "next larger" and "next smaller" functions, or more precisely, 
nextAwayFromZero and nextTowardsZero functions. nextTowardsZero is of course a 
special case of nextafter, but nextAwayFromZero doesn't match any of these.)

----------
nosy: +tim.peters

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39288>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to