Discuss Scratch
- Discussion Forums
- » Suggestions
- » Could we please have an exponents block? ( ) ^ ( )
- Cyoce
- Scratcher
500+ posts
Could we please have an exponents block? ( ) ^ ( )
That project doesn't work. It doesn't even work for all integers, let alone decimals. Not sure how to get exponents for decimals, but here's how it works for integers:There now is. But what if we wanted, for example 84 ^ 59? There's no block for that.
This project.
EDIT: 84 ^ 59 = 3.40782965354148e+113. Boom.
define exponentify (x), (y)
set [result v] to [1]
if <(y) > [0]> then
repeat (y)
set [result v] to ((result) * (x))
end
else
repeat (y)
set [result v] to ((result) / (x))
- lalala3
- Scratcher
100+ posts
Could we please have an exponents block? ( ) ^ ( )
Like so:
Well, not really. The “base” and the “log” should be switched, but whatever. The problem with this is that the very idea that one might be forced to do this is fundamentally absurd for reasons that should be clear to anyone who's learned about logarithmic functions in math class. Support, even though((base) ^ (log) :: operators)is exactly the same as([10^ v] of ((base) * ([log v] of (log) :: operators)) :: operators)
- lalala3
- Scratcher
100+ posts
Could we please have an exponents block? ( ) ^ ( )
No. Technically, it's only necroposting if the topic has been resolved. It's just that people don't think and instead pull out their torches and pitchforks whenever someone posts on an old thread, regardless of whether the topic has actually been resolved, so the word (as well as the concept) has become depreciated.I know this is technically necroposting but you raise a good point! An exponent block would certainly make things easier for teachers working with Scratch! Please, please, please add this as an operator just like +-*/ it's a real limitation when teaching a lot of math concepts not to have exponentiation.
- lalala3
- Scratcher
100+ posts
Could we please have an exponents block? ( ) ^ ( )
Reposting from another thread, because it's relevant:
I just figured out something. Neither of the workarounds are perfect. The one using loops has issues with raising numbers to negative or fractional powers, while the other workaround (using logs) doesn't work if the base isn't positive. I thus propose the following solution:Define (base) ^ (exponent)Can we have a proper exponent block now? Please?
if <(base :: custom) > (0)> then
set [answer v] to ([10 ^ v] of ((exponent) * ([log v] of (base))))
else
if <((exponent) mod (1)) = (0)> then
set [answer v] to [1]
repeat ([abs v] of (exponent))
set [answer v] to ((answer) * (base))
end
if <(exponent) < (0)> then
set [answer v] to ((1)/(answer))
end
else
set [answer v] to [undefined]
end
end
- RalphMath
- New to Scratch
27 posts
Could we please have an exponents block? ( ) ^ ( )
Well, the actual value of 3.14 ^ 3.14 is approximately 36.3378. Anyone considering writing an exponentiation block really needs to understand how logarithms and powers work.Actually, 3.14 ^ 3.14 results in 30.959 on my custom block (about seven posts above). Try it. It just doesn't work with negative numbers or fractions. And my project barely involves any heavy scripting or math at all. All you need is: The short version works for all real numbers, the long one doesn't.
- three variables
- a repeat block
- a subtraction and a multiplication block
- a set variable block
That's it. It took me like two minutes.
- RalphMath
- New to Scratch
27 posts
Could we please have an exponents block? ( ) ^ ( )
Here's my attempt, it might be a bit faster for large negative exponents since it doesn't loop.
define exp (value, power)
if <<[value] < [0 ]> and << [power] mod [1]> > [0]>> then
set [answer] to [ ]
else
set [answer] to ([e^ v] of ([power] * ([ln v] of ([abs v] of [value])))
if <([value] < [0]) and (([power] mod [2]) = [1])> then
set [answer] to ([answer] * [-1])
end
- BOTBOOM421
- Scratcher
11 posts
Could we please have an exponents block? ( ) ^ ( )
define x to the power of y
- pokejofe
- Scratcher
68 posts
Could we please have an exponents block? ( ) ^ ( )
Support!
if <([10^ v] of (( power) * ([log v] of ( base))) :: operators) = (( base) ^ ( power) :: operators)> then
say [This makes sense]
else
say [I think the kumquats made this bug]
end
Generation 377: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment. I did not start this
Kumquats haven't eaten my signature! although I don't know what has…
Edit: I figured out what ate my signature! nothing. A bee stung it!
but I have seen some apples that looked like troublemakers hanging around it lately…
- DownsGameClub
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
Lets keep the spam down.
As for the suggestion, I would support. It would not be very easy using those
As for the suggestion, I would support. It would not be very easy using those
(((((((((...) * (0)) * (0)) * (0)) * (0)) * (0)) * (0)) * (0)) * (0))blocks…
–DGC
Scratcher since Aug. 2015 +++ Fire Alarm Enthusiast +++ College student studying fire protection engineering
- Tymewalk
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
Support. There's no reason not to have this, seeing as how the workarounds (even just multiplying several times) get out of hand quickly.
bold thing - italic thing - underlined thing - strikethrough thing
- TheLogFather
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
If this is going to be the ‘official’ exponent suggestion topic, then I guess I'd better make sure there's a link to this in here:
- https://scratch.mit.edu/projects/16871883/ -
Note the features, which deal with some of the issues mentioned here when using the e^/ln workaround.
- https://scratch.mit.edu/projects/16871883/ -
Note the features, which deal with some of the issues mentioned here when using the e^/ln workaround.
Last edited by TheLogFather (Jan. 15, 2016 14:00:47)
Siggy the Kumquat slayer:
Main account: DadOfMrLog –– Frameworks for basic pen-rendered 3D in scratch (see studio). Examples:
- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -
- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -
- BookOwl
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
Support
who needs signatures
- superben100
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
Support!
But…
^_^
But…
(((y) / (2)) * ((x) * (x)))x ^ y
^_^
Last edited by superben100 (May 21, 2016 02:16:03)
Hello there!
I've been a Scratcher for nine years now, and I'm always happy to help!
I'm not around too often, but I check in here from time to time.
Let me know if you need anything!
|| Probably vibing to “Try” - Lawrence ||
I've been a Scratcher for nine years now, and I'm always happy to help!
I'm not around too often, but I check in here from time to time.
Let me know if you need anything!
|| Probably vibing to “Try” - Lawrence ||
- Owengren
- Scratcher
100+ posts
Could we please have an exponents block? ( ) ^ ( )
My project needs one! But, I have a workaround:I was thinking of making a calculator project.Yes, but how many projects need a x^y block? yes, but same can be said of the change x/y by and go to blocks… They aren't necessary, but for new scratchers are a great help.
define (x) ^ (y)
set [output v] to [0]
repeat (y)
change [output v] by (([sin v] of (y)) / (([floor v] of (x)) + ((length of ((y) * (10))) - ([abs v] of ((x) + ((y) - ((x) / (4))))))))
Go check out Cosmic Chasers - my new 2.5D game!
https://scratch.mit.edu/projects/414358692/
Cosmic Chasers might move to a new account. Here's why:
https://scratch.mit.edu/projects/415189579/
- Lythium
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
^^^ and this is why we need powers.My project needs one! But, I have a workaround:I was thinking of making a calculator project.Yes, but how many projects need a x^y block? yes, but same can be said of the change x/y by and go to blocks… They aren't necessary, but for new scratchers are a great help.define (x) ^ (y)
set [output v] to [0]
repeat (y)
change [output v] by (([sin v] of (y)) / (([floor v] of (x)) + ((length of ((y) * (10))) - ([abs v] of ((x) + ((y) - ((x) / (4))))))))
- 24691357
- Scratcher
100+ posts
Could we please have an exponents block? ( ) ^ ( )
This is 3.14^3, and a better workaround (it's a reporter) is:Actually, 3.14 ^ 3.14 results in 30.959 on my custom block (about seven posts above). Try it. It just doesn't work with negative numbers or fractions. And my project barely involves any heavy scripting or math at all. All you need is: The short version works for all real numbers, the long one doesn't.
- three variables
- a repeat block
- a subtraction and a multiplication block
- a set variable block
That's it. It took me like two minutes.
([10^ v] of ([second] * ([log v] of [first]) :: pen) :: operators )Used zebra coloring for convenience
Last edited by 24691357 (July 22, 2016 07:06:01)
If it is in India, I'm Indian, including i-words.
24691357
Safe cloud chat https://scratch.mit.edu/projects/116768922/
- TheMonsterOfTheDeep
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
…that's not a workaround…My project needs one! But, I have a workaround:I was thinking of making a calculator project.Yes, but how many projects need a x^y block? yes, but same can be said of the change x/y by and go to blocks… They aren't necessary, but for new scratchers are a great help.define (x) ^ (y)
set [output v] to [0]
repeat (y)
change [output v] by (([sin v] of (y)) / (([floor v] of (x)) + ((length of ((y) * (10))) - ([abs v] of ((x) + ((y) - ((x) / (4))))))))
(sorry for the bump)
Last edited by TheMonsterOfTheDeep (Aug. 9, 2016 06:36:43)
my latest extension: 2d vector math
- savaka
- Scratcher
1000+ posts
Could we please have an exponents block? ( ) ^ ( )
I added some arguments for the power block
THERE IS NO REAL WORKAROUND
THERE IS NO REAL WORKAROUND