[Tutor] [newbie alert] why can't I find a function that gives me the sign of an integer?
Wolfram Kraus
kraus at hagen-partner.de
Fri Jan 27 12:19:45 CET 2006
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 <http://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
>
>
If you can accept False,0,True instead of -1,0,1 you can use:
x and x == abs(x)
HTH,
Wolfram
More information about the Tutor
mailing list