Discuss Scratch

PH-zero
Scratcher
100+ posts

Math: "abridge" a number

Hey
Is there an easy/smart way to do the following:

Set X to (abridge (X) )

if X=2, then X will be 1

if X=-2, then X will be -1

got the idea?

-3__-2__-1__0__1__2__3 subtraction
< <

-3__-2__-1__0__1__2__3 “abridge”
> <
I didn't put this into suggestions because i thought there's already
a possibility to do this.

PH-zero

Ever wanted to rotate the stage? Or to
go to x:() y:() z:() ::custom
Click me!
Psiborg
Scratcher
500+ posts

Math: "abridge" a number

PH-zero wrote:

Hey
Is there an easy/smart way to do the following:

Set X to (abridge (X) )

if X=2, then X will be 1

if X=-2, then X will be -1

got the idea?

-3__-2__-1__0__1__2__3 subtraction
< <

-3__-2__-1__0__1__2__3 “abridge”
> <
I didn't put this into suggestions because i thought there's already
a possibility to do this.

PH-zero
Do you mean like: set X to X - (X/ abs X)

Save the world from giant ants in a classic tower defense: Antfestation
Protect the Minions from the Purples in Minion Push
Collect treasure across the beautiful islands of Mylands
Guard your gold in The Hoard++
Remake of a classic arcade game: Descentipede

drmcw
Scratcher
1000+ posts

Math: "abridge" a number

Psiborg wrote:

PH-zero wrote:

Hey
Is there an easy/smart way to do the following:

Set X to (abridge (X) )

if X=2, then X will be 1

if X=-2, then X will be -1

got the idea?

-3__-2__-1__0__1__2__3 subtraction
< <

-3__-2__-1__0__1__2__3 “abridge”
> <
I didn't put this into suggestions because i thought there's already
a possibility to do this.

PH-zero
Do you mean like: set X to X - (X/ abs X)

I'd guess that's what was wanted however you need to be careful when x is 0 and not sure it'd be as fast as the more clunky;
if x > 0
set x to x -1
else
set x to x +1

(again would also probably want to check for 0; not to avoid a divide by zero but to prevent it returning 1 instead of 0.)

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
PH-zero
Scratcher
100+ posts

Math: "abridge" a number

Do you mean like: set X to X - (X/ abs X)
exactly, just a smarter way to do it, ya know?
like just

Set X to (abridge (X) )

there is a block which says ( sqrt of ( ) )
And you can choose other things like abs or sin etc.
maby this way somehow?

if x > 0
set x to x -1
else
set x to x +1

You'r, right, but i'd like to do it without if.

But anyways, thank you both for your help

Ever wanted to rotate the stage? Or to
go to x:() y:() z:() ::custom
Click me!

Powered by DjangoBB

Standard | Mobile