sign math block?

Shadowblitz16

  • Posts: 44
how can i sign something for example...
sign(-12) = -1
sign(35) = 1
sign(0) = 0
sign(99999999999999999) = 1
sign(-99999999999999999) = -1

Hectate

  • *
  • Posts: 4643
If you have non-zero numbers, you can divide the number by it's own absolute value to get the sign. Division is clunky though, and if you just create your own custom block (function) you can easily use If/Else statements to do this.
Additionally, doing so would let you decide what to do with zeros, instead of dividing by zero and crashing.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Shadowblitz16

  • Posts: 44
i'm not sure how custom blocks work though :/

tomtomtom

  • Posts: 22
Just create 2 number attributes: one for your number to be checked (CheckSign), one for your Sign-check (SignOutput)

If CheckSign is > 0
Set SignOutput to 1
If CheckSign = 0
Set SignOutput to 0
If CheckSign < 0
Set SignOutput to -1