## Discuss Scratch

- savaka
- Scratcher

1000+ posts

### Power block

This makes me think, they should add this:

(() √ ()) // category=operators

*Last edited by savaka (Dec. 26, 2013 23:17:03)*

- frodewin
- Scratcher

500+ posts

### Power block

Support for a new ((x) ^ (y)) block.

1. it is simpler than other solutions

2. it is faster than other solutions

3. at least in the form ((x) ^ (2)) it will be used a lot

4. young scratchers (below 10) might not know what ^is, but the same holds for log, sin, cos, mod, … - at least the code of others becomes easier to read

1. it is simpler than other solutions

2. it is faster than other solutions

3. at least in the form ((x) ^ (2)) it will be used a lot

4. young scratchers (below 10) might not know what ^is, but the same holds for log, sin, cos, mod, … - at least the code of others becomes easier to read

((x) ^ (y))(but in green)

*Last edited by frodewin (Dec. 23, 2013 18:06:47)*

- mariobros406
- Scratcher

500+ posts

### Power block

You mean like

(() ^ ()) // category=operatorsAnyway…

That block kinda already exists: This makes me think, they should add this:(() √ ()) // category=operators

([sqrt v] of ())Also, that block would make you input the answer. It would be a boolean block, not a reporter block.

*Last edited by mariobros406 (Dec. 23, 2013 21:02:41)*

I only check in to Scratch from time to time to see what others have been up to. I don't really post anything anymore. I'll occasionally post a question in the AT forum if I can't find an answer anywhere else.

- sccar3
- Scratcher

100+ posts

### Power block

No, a You mean like(() ^ ()) // category=operatorsAnyway…That block kinda already exists: This makes me think, they should add this:(() √ ()) // category=operators([sqrt v] of ())Also, that block would make you input the answer. It would be a boolean block, not a reporter block.

(() √ ()) // category=operatorsblock would be a reporter. The first number would be the index or degree while the second would be the radicand. When we say “square root” that means it has an index of 2, since squares are 2 dimensional. If a number was cubed (having an index of 3) you find what number multiplies by itself 3 times to get that number, rather than the 2 from a square root.

10-year Scratch veteran. Fight me.

- savaka
- Scratcher

1000+ posts

### Power block

You can set categories? Cool! Changing… You mean like(() ^ ()) // category=operatorsAnyway…That block kinda already exists: This makes me think, they should add this:(() √ ()) // category=operators([sqrt v] of ())Also, that block would make you input the answer. It would be a boolean block, not a reporter block.

- mariobros406
- Scratcher

500+ posts

### Power block

Yup. But don't use it too often…it's top secret!You can set categories? Cool! Changing… You mean like(() ^ ()) // category=operatorsAnyway…(() √ ()) // category=operators([sqrt v] of ())Also, that block would make you input the answer. It would be a boolean block, not a reporter block.

I only check in to Scratch from time to time to see what others have been up to. I don't really post anything anymore. I'll occasionally post a question in the AT forum if I can't find an answer anywhere else.

- 1234abcdcba4321
- Scratcher

1000+ posts

### Power block

You mean like(() ^ ()) // category=operatorsAnyway…

No, a(() √ ()) // category=operatorsblock would be a reporter. The first number would be the index or degree while the second would be the radicand. When we say “square root” that means it has an index of 2, since squares are 2 dimensional. If a number was cubed (having an index of 3) you find what number multiplies by itself 3 times to get that number, rather than the 2 from a square root.

Too easy workaround.

(((1) / (amount)) ^ (other amount)) // category=operators

Not too top-secret when you tell everyone that asksYup. But don't use it too often…it's top secret! You can set categories? Cool! Changing…

*Last edited by 1234abcdcba4321 (Dec. 26, 2013 19:31:11)*

I'd highly appreciate it if you were to follow me. Don't forget to go to my profile.

All of my programming suggestions <— You should really get the suggestions move back to the suggestions forum!

Five hundred posts! I never expected to get up there… In only 2-3 months.

Does anyone know what a signature is? I mean, I've already seen 6-7 people get confused.

- savaka
- Scratcher

1000+ posts

### Power block

Yup. But don't use it too often…it's top secret!You can set categories? Cool! Changing… You mean like(() ^ ()) // category=operatorsAnyway…(() √ ()) // category=operators([sqrt v] of ())Also, that block would make you input the answer. It would be a boolean block, not a reporter block.

1. You can just see the code by rolling over any of the blocks on the first menu.You mean like(() ^ ()) // category=operatorsAnyway…

No, a(() √ ()) // category=operatorsblock would be a reporter. The first number would be the index or degree while the second would be the radicand. When we say “square root” that means it has an index of 2, since squares are 2 dimensional. If a number was cubed (having an index of 3) you find what number multiplies by itself 3 times to get that number, rather than the 2 from a square root.

Too easy workaround.(((1) / (amount)) ^ (other amount)) // category=operatorsNot too top-secret when you tell everyone that asksYup. But don't use it too often…it's top secret! You can set categories? Cool! Changing…

2. You're right, the workaround is easy, but no everyone knows that.

- frodewin
- Scratcher

500+ posts

### Power block

You mean like(() ^ ()) // category=operatorsAnyway…

No, a(() √ ()) // category=operatorsblock would be a reporter. The first number would be the index or degree while the second would be the radicand. When we say “square root” that means it has an index of 2, since squares are 2 dimensional. If a number was cubed (having an index of 3) you find what number multiplies by itself 3 times to get that number, rather than the 2 from a square root.

Too easy workaround.(((1) / (amount)) ^ (other amount)) // category=operators

Not exactly, the workaround for the n-th square root of x would be

((x) ^ ((1) / (amount))) // category=operators

Therefore I don't think we would need an n-th square root block, but a power block would be useful.

- mariobros406
- Scratcher

500+ posts

### Power block

(() ^ ()) // category=operatorsAnyway…

No, a(() √ ()) // category=operatorsblock would be a reporter. The first number would be the index or degree while the second would be the radicand. When we say “square root” that means it has an index of 2, since squares are 2 dimensional. If a number was cubed (having an index of 3) you find what number multiplies by itself 3 times to get that number, rather than the 2 from a square root.

Too easy workaround.(((1) / (amount)) ^ (other amount)) // category=operatorsNot too top-secret when you tell everyone that asksYup. But don't use it too often…it's top secret! You can set categories? Cool! Changing…

I only check in to Scratch from time to time to see what others have been up to. I don't really post anything anymore. I'll occasionally post a question in the AT forum if I can't find an answer anywhere else.

- savaka
- Scratcher

1000+ posts

### Power block

Square root is only 2√. n√ is not also a square root.(() ^ ()) // category=operatorsAnyway…

No, a(() √ ()) // category=operatorsblock would be a reporter. The first number would be the index or degree while the second would be the radicand. When we say “square root” that means it has an index of 2, since squares are 2 dimensional. If a number was cubed (having an index of 3) you find what number multiplies by itself 3 times to get that number, rather than the 2 from a square root.

Too easy workaround.(((1) / (amount)) ^ (other amount)) // category=operators

Not exactly, the workaround for the n-th square root of x would be((x) ^ ((1) / (amount))) // category=operators

Therefore I don't think we would need an n-th square root block, but a power block would be useful.

- davidkt
- Scratcher

1000+ posts

### Power block

Support, but I think it should be

(() ** ())//category=operators

Remember when I looked like this? I still do.

Float, my Scratch 2.0 mod | My (somewhat under-construction) blog

Float, my Scratch 2.0 mod | My (somewhat under-construction) blog

- savaka
- Scratcher

1000+ posts

### Power block

I don't get it. Support, but I think it should be(() ** ())//category=operators

(() ^ ()) // category=operatorsis the actual symbol for power and people would understand it.

- scubajerry
- Scratcher

1000+ posts

### Power block

OK, so here's my definitive x^y custom block… The thing is that you can't do negative numbers with logs.define result = (x) ^ (y)That should cover everything but non-integer powers of negative numbers (which gets a bit hairy…), and it makes sure that integer raised to integer gives exactly an integer (in case you assume you'll get an integer, perhaps because you check for equality with an integer at some point).

if <(y) = [0]> then

set [result v] to [1] // yes, we also include 0^0=1 :O

else

if <(x) = [0]> then

set [result v] to [0] // 0^y=0 for any y except zero (see above)

else

set [result v] to ([e^ v] of ((y)*([ln v] of ([abs v] of (x)))) // no negative x for now

if <(x) < [0]> then // now deal with power of negative number

if <(round(y)) = (y)> then // we can do integer powers of negative numbers

if <((y) mod (2)) = [1]> then

set [result v] to ((0) - (result)) // odd powers will be negative

end

else

set [result v] to [NaN] // but let's not go there at this stage...

end

end

if <<(y) > [0]> and <<(round(x)) = (x)> and <(round(y)) = (y)>>> then

set [result v] to (round (result)) // ensure we get exactly an integer if both x & y were ints

end

end

end

Hope I've got that all right!

Have you put this is a project?

- DadOfMrLog
- Scratcher

1000+ posts

### Power block

OK, here it is: Have you put this is a project?

http://scratch.mit.edu/projects/16871883

(Plus a couple of extra tweaks)

*Last edited by DadOfMrLog (Jan. 22, 2014 19:15:34)*

Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…

- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

- ev3commander
- Scratcher

500+ posts

### Power block

I'm 7 and know that.. Support for a new ((x) ^ (y)) block.

1. it is simpler than other solutions

2. it is faster than other solutions

3. at least in the form ((x) ^ (2)) it will be used a lot

4. young scratchers (below 10) might not know what ^is, but the same holds for log, sin, cos, mod, … - at least the code of others becomes easier to read((x) ^ (y))(but in green)

- Haiming
- Scratcher

1000+ posts

### Power block

You could just use a repeat block…

*Last edited by Haiming (July 9, 2014 13:24:29)*

- savaka
- Scratcher

1000+ posts

### Power block

Now I get it. ** is how they do it in Python. But this isn't Python. It's Scratch. And people know it as ^, because that's the math symbol. Support, but I think it should be(() ** ())//category=operators