[Tutor] why can't I find a function that gives me the sign of an integer?
Rinzwind
w.damen at gmail.com
Fri Jan 27 13:22:01 CET 2006
On 1/27/06, Wolfram Kraus <kraus at hagen-partner.de> 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 <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
> >
> >
> >
> D'Oh!
>
> It works with -1/0/1, too:
> x and x/abs(x)
>
> >>> x = -2
> >>> x and x/abs(x)
> -1
> >>> x = 2
> >>> x and x/abs(x)
> 1
> >>> x = 0
> >>> x and x/abs(x)
> 0
>
> HTH,
> Wolfram
No, I needed the -1 0 and 1 :-)
That way whatever you move (like Qd2-d6 or Qd6-d2) I could find the
places in between the 2. Same goes for Rd1-Rd8 or Rd8-Rd1). I needed
it to multiply with -1, 0, 1 according to what move it was :-)
Oh and I allready got it working so I'm all :-) :-) :-) about it.
More information about the Tutor
mailing list