[Python-ideas] Why no sign function?

Mark Dickinson dickinsm at gmail.com
Mon Apr 26 23:44:43 CEST 2010


On Mon, Apr 26, 2010 at 10:36 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
> If a sign function were implemented, I'd probably want something like
> IEEE 754's signbit function

Correction:  it's C99 that has a signbit function.  IEEE 754-2008
specifies an 'isSignMinus' function with exactly the same semantics:
values with the sign bit set (including -0.0, -inf, and NaNs whose
sign bit is set) return True;  other values return False.

I wouldn't object to a `math.is_signed` function or a
`float.is_signed` method with these semantics.  It's not clear where
is the better place:  we have `math.isnan` and `math.isinf`, but
`float.is_integer`.

Mark



More information about the Python-ideas mailing list