[Tutor] [newbie alert] why can't I find a function that gives me the sign of an integer?

Rinzwind w.damen at gmail.com
Thu Jan 26 21:00:03 CET 2006


Thank you!
*opens manual again*

Wim

On 1/26/06, Orri Ganel <singingxduck at gmail.com> wrote:
>
> Rinzwind wrote:
>
> In basic I can use SGN to get back -1, 0,  +1 if a number is <0, 0, >0.
> I searched on  the web for a bit but sgn and sign give me way too many
> discussions about Decimals. python.org with numbers/digits doesn't tell
> about a function.
>
> Maybe Python uses a different name for it so I am not looking for the
> correct wording :( Sucks not knowing syntax from my memory and having to
> look them up alot).
>
> Wim
>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.orghttp://mail.python.org/mailman/listinfo/tutor
>
>
> Well, the cmp() function does this if you compare the number to 0:
>
> >>> cmp(-34,0)
> -1
> >>> cmp(0,0)
> 0
> >>> cmp(23,0)
> 1
>
> Of course, that's not all cmp() is good for, but it would work in this
> case.
>
> HTH,
> Orri
>
> --
> Email: singingxduck AT gmail DOT com
> AIM: singingxduck
> Programming Python for the fun of it.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060126/c9309862/attachment.html 


More information about the Tutor mailing list