[issue27739] add math.sign/signum

2016-08-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thanks David.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread R. David Murray

R. David Murray added the comment:

This has been previously discussed and rejected, in issue 829370.

--
nosy: +r.david.murray
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> math.signum(int)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

copysign() is part of the standard C maths library (that is why it was added to 
the math module).

sgn/sign/signum was used in old languages that didn't have copysign() (Basic, 
Pascal, etc).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread Steven D'Aprano

Steven D'Aprano added the comment:

If this is added, should this signum function be the two value version that 
returns 1 for zero, or the three value version that returns 0? Should it 
distinguish between signed zeroes +0.0 and -0.0? What should it do for NANs 
(raise, return a NAN, copy the sign bit from the NAN)?

The argument for adding this will be slightly stronger if other languages have 
this, and especially if it is part of the standard C maths library.

In any case, there's only a few more days until the 3.6 feature freeze, so 
unless you have an implementation and tests ready to go, the earliest it could 
be added will be 3.7.

Serhiy: if this gets added, then it would make sense to add cmath.signum to 
handle complex numbers.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

sgn(x) is the same as copysign(1.0, x).

The math module doesn't support complex numbers and shouldn't.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread Ankur Dedania

Ankur Dedania added the comment:

sign/signum isn't the same as copysign, and doesn't support complex numbers

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See math.copysign().

https://docs.python.org/3/library/math.html#math.copysign

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27739] add math.sign/signum

2016-08-11 Thread Ankur Dedania

New submission from Ankur Dedania:

Add a new function to the math module sign/signum 
https://en.wikipedia.org/wiki/Sign_function

--
messages: 272459
nosy: AnkurDedania
priority: normal
severity: normal
status: open
title: add math.sign/signum
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com