Discuss Scratch

scratchisthebest
Scratcher
1000+ posts

Power block

Even better than that huge script: this block!

(() ^ ())

I am a Lava Expert
1234abcdcba4321
Scratcher
1000+ posts

Power block

The ^: To the power of.

I need this in my current project, and so far, the only way I can do it is by making a different variable just so my value can go up just the right amount.

Also, rename and delete functions for variables? I know delete was in 1.4, why was it deleted?

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.
ErnieParke
Scratcher
1000+ posts

Power block

The delete button wasn't deleted in Scratch 2.0; it's still there. Right click a variable in the block palette, and you can delete it and rename it.

About the ^ power, I'd just like to point out a workaround:

([10 ^ v] of ((power) * ([log v] of (base))))

Showing,

ErnieParke

AonymousGuy
Scratcher
1000+ posts

Power block

I support, because sometimes I have to use it.

Or, if we could get custom reporter blocks, we could just make one of those.
ProdigyZeta7
Scratcher
1000+ posts

Power block

ErnieParke wrote:

([10 ^ v] of ((power) * ([log v] of (base))))
And to prove this works:

10 ^ (b log a) = x >Setting up the equation
log 10 ^ (b log a) = log x >Property of logarithms
(b log a) log 10 = log x >Bringing the exponent down
b log a = log x >log 10 = 1
log (a ^ b) = log x >Bringing the exponent back to the base
a ^ b = x >Getting rid of log



Firedrake969
Scratcher
1000+ posts

Power block

-5^2.

I support… the workaround doesn't perfectly work.

log base X of a negative number is undefined. (unless in some rare cases the base is negative, but that doesn't happen in Scratch)

Last edited by Firedrake969 (Nov. 17, 2013 20:53:34)


'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
1234abcdcba4321
Scratcher
1000+ posts

Power block

Well, you could always do

if <(base) > [0]> then
([10 ^ v] of ((power) * ([log v] of (base))))
else
((0) - ([10^ v] of ((power) * ([log v] of ([abs v] of (base))))))
end

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.
Firedrake969
Scratcher
1000+ posts

Power block

Bumping because of a duplicate I found.

The workaround doesn't allow for negative numbers. ^ does.

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
seanbobe
Scratcher
500+ posts

Power block

savaka wrote:

I understand all these work, but wouldn't a block be way easier for new Scratchers? I have no idea what logarithms are.
correct
you dont teach logarithms in 5th grade!


Sadly my kumquat was eaten by an evil signature.
_______________
|My internets.…..|
\Kumquat Shield/
Firedrake969
Scratcher
1000+ posts

Power block

Some of us did

But yeah, for some odd reason, kids are taught exponents way before logs, but logs and exponents are analogous to multiplication and division.

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
mitchboy
Scratcher
1000+ posts

Power block

scratchisthebest wrote:

Even better than that huge script: this block!
you call that huge? that's a rather simple script.

Firedrake969 wrote:

Bumping because of a duplicate I found.

The workaround doesn't allow for negative numbers. ^ does.
yes it does. all you have to do is add this:
if <(x) < [0]> then
set [result v] to ((1) / (result))
end

and tell me one other reason to add this other than for making a calculator. sorry, but i think this is very low on the st's priorities.

Last edited by mitchboy (Nov. 20, 2013 00:12:56)


Capsicum annuum.
mathfreak231
Scratcher
1000+ posts

Power block

DadOfMrLog wrote:

define result = (x) ^ (y)
if <(y) = [0]> then
set [result v] to [1] // yes, we also include 0^0=1 :O
Last time I checked, 0^0 was undefined.

3DS FC: 3239-6065-2543 (Ask me before adding) | AS: Alex~ | X: Alex (DWS)
Ask me on my profile about XYORAS breeding requests!

My browser / operating system: MacOS Macintosh X 10.11.3, Safari 9.0.3, Flash 20.0 (release 0)
DadOfMrLog
Scratcher
1000+ posts

Power block

mathfreak231 wrote:

Last time I checked, 0^0 was undefined.
Technically, it's an "indeterminate form", yes.

However, for practical computation it's typically given the value one - and doing that also helps along several useful mathematical theorems…

(EDIT: actually, wikipedia gives a really decent overview of the 0^0 question, including treatment on computers.)

Firedrake969 wrote:

The workaround doesn't allow for negative numbers. ^ does.
See my (supposedly really long) script for a slightly more thorough treatment of negative numbers.

However, note that a^b with both a & b negative (and b not an integer) is certainly not for the faint-hearted - I'd be really interested to know how the proponents of the a^b block would see it behaving under such situations…

Last edited by DadOfMrLog (Nov. 20, 2013 02:26:36)



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 -

jh1234l
Scratcher
100+ posts

Power block

Poemon1_REMIX wrote:

SuperNicky wrote:

power what do you mean power?
like 5^2 = 25, or 2^3 = 8.

(^ is power)

Basically, if you have 5^5, it is 5x5x5x5x5. If you have 5^4, it is 5x5x5x5, and so on.
Basically, is the number multiplying by itself that many times.

Two Advertising and sharing groups:
Scratch Cat's Hideout: Home Page / Advertise! / Members / Write A Review / Read A Review / FAQs
Scratching fame:

jh1234l
Scratcher
100+ posts

Power block

A () ^ () block is not necessary right now, as you could just use the workaround and add a script to check if it is zero.
However, it is certainly nice to have.

Two Advertising and sharing groups:
Scratch Cat's Hideout: Home Page / Advertise! / Members / Write A Review / Read A Review / FAQs
Scratching fame:

1234abcdcba4321
Scratcher
1000+ posts

Power block

And, wouldn't the workaround work, if you just put an abs() around the base value?

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.
ErnieParke
Scratcher
1000+ posts

Power block

1234abcdcba4321 wrote:

And, wouldn't the workaround work, if you just put an abs() around the base value?
No, it wouldn't work because let's take the example:

2^3

It equals 8. Meanwhile:

(-2)^3

It equals -8. Then you get into the problem of fractional powers, and I haven't been able to figure that out.

Pointing out,

ErnieParke

goldfish678
Scratcher
1000+ posts

Power block

I think the scratch team might have said they're not going to add it and there's a workaround.

when she said
forever
play sound [aaaaaaaaaaaaa v] until done
end
i really felt that
savaka
Scratcher
1000+ posts

Power block

scratchisthebest wrote:

by this logic, we can remove “move (10) steps”

why not just use
go to x: ((x position) + ([cos v] of ((direction)*(amt)))) y ((x position) + ([sin v] of ((direction)*(amt))))
i mean jeez so simple
Scratch is made to be for kids to learn how to program. It's not for professionals. I don't know how to use trigonometry to move a sprite.
supero
Scratcher
11 posts

Power block

Or this too!



((x) * ((x) * ((x) * (.....))))

Just keep repeating it as many powers as you need it to.

Last edited by supero (Dec. 23, 2013 00:58:44)


"I always finish projects last in school; not because I had no ideas, but because I had too many." -Me.

Powered by DjangoBB

Standard | Mobile