signum() not in math?

Dinu Gherman gherman at darwin.in-berlin.de
Fri Oct 12 07:42:22 EDT 2001


Des Small wrote:
> 
> The only possible controversy would be the definition at zero.  I
> usually define signum(0) = 0, but others may not.  I don't even want
> to think about the differences between +0 and -0 in this case.

Well, I'm surethis can be solved, and, no worries, there doesn't 
seem to be any such difference between -0 and +0 in Python:

PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on
win32.
>>> -0 < +0
0
>>> -0 > +0
0
>>> -0 == +0
1
>>> -0. == +0.
1
>>> -0. < +0.
0
>>> -0. < +0
0

> I certainly endorse the sentiment that it should be available in the
> standard library, but now that I come to look (and prompted by your
> use of "sign()") I find that there _is_ a sign function in Numeric.
> Since I always use Numeric, this removes much of the urgency.

Which is sort of a SIGNificant overhead for using one function, 
isn't it? ;-) (Ha - if you don't take it, write your own!)

> I think there is a sentiment that Numeric should be absorbed into the
> standard library, after the code has been cleaned up (which noone has
> time to do).

Oh, really? I argued for that three years ago, maybe. The 
response was sort of "Who needs that in standard Python?"
Good to see times changing for the better... If only the 
same would happen to the documentation... sigh!

Dinu

-- 
Dinu C. Gherman
ReportLab Consultant - http://www.reportlab.com
................................................................
"The world becomes a better place as a result of the refusal
to bend to authority and doctrine." (Noam Chomsky)



More information about the Python-list mailing list