Discuss Scratch
- Discussion Forums
- » Suggestions
- » General Exponent Operator
- lalala3
-
Scratcher
100+ posts
General Exponent Operator
I've been feeling inspired lately, so I decided to finally create a topic to express all my thoughts on this subject.
Before I begin, I'd like to intercept anyone about to post a workaround involving a) repeated multiplication or b) e^(power*ln(base)).
First, this suggestion is not entirely about just adding ()^(), as you'll see after reading through this post–but that can come later.
Second, these workarounds don't even work all the time, which some of you who have posted on other topics involving adding ()^() would know if you'd bothered to continue watching the topic after having made your post. But for everyone's convenience, I'll post a counterargument in the topic post, so people can read it before posting:
That's a lot of trouble to go through just to have a basic operator.
Now, on to my actual suggestion. I think that the 10^ and e^ blocks should be removed, and replaced with a more general function that allows the programmer to input the base. Being forced to use a workaround for a basic function (or operator) involving complex manipulation of a more limited version of the function itself is making us jump through hoops in order to attain basic functionality. It's okay for the logarithmic function since that's pretty much standard, logarithms are less common, and the workaround is really easy, but that is absolutely not the case for exponentiation, as I've already shown. The current system of using 10^ and e^ blocks doesn't seem to be a good way of doing things, and should be replaced.
Before I begin, I'd like to intercept anyone about to post a workaround involving a) repeated multiplication or b) e^(power*ln(base)).
First, this suggestion is not entirely about just adding ()^(), as you'll see after reading through this post–but that can come later.
Second, these workarounds don't even work all the time, which some of you who have posted on other topics involving adding ()^() would know if you'd bothered to continue watching the topic after having made your post. But for everyone's convenience, I'll post a counterargument in the topic post, so people can read it before posting:
((-0.5) ^ (-2) ::operators) //Evaluates to 4Both of the two mentioned workarounds are unable to process this expression. The negative exponent trips up a repeat block, which is unable to handle values that aren't whole numbers, while logs and lns don't work if you enter in a negative. A way to get around these issues is shown below:
define Raise (base) to (exp)(Credit to RalphMath, with modifications because I like powers of 10 better than powers of e for programming purposes)
if <<(base) < [0]> and <<(exp) mod [1]> > [0]>> then
return[] // imaginary
end
if <<(base) < [0]> and (((exp) mod [2]) = [1])> then // odd power of negative number
return(([10 ^ v] of (([log v] of ([abs v] of (base))) * (exp))) * [-1])
else // even power of any number
return([10 ^ v] of (([log v] of ([abs v] of (base))) * (exp)))
end
That's a lot of trouble to go through just to have a basic operator.
Now, on to my actual suggestion. I think that the 10^ and e^ blocks should be removed, and replaced with a more general function that allows the programmer to input the base. Being forced to use a workaround for a basic function (or operator) involving complex manipulation of a more limited version of the function itself is making us jump through hoops in order to attain basic functionality. It's okay for the logarithmic function since that's pretty much standard, logarithms are less common, and the workaround is really easy, but that is absolutely not the case for exponentiation, as I've already shown. The current system of using 10^ and e^ blocks doesn't seem to be a good way of doing things, and should be replaced.
Last edited by lalala3 (Jan. 20, 2015 03:33:27)
- Thepuzzlegame
-
Scratcher
1000+ posts
General Exponent Operator
I have seen this suggested so many times, and as always I support! Seriously, I don't know why this isn't implemented yet.
- Iditaroid
-
Scratcher
500+ posts
General Exponent Operator
I really don't know why they've never added this! I dont remember ever seeing any explanation why and Scratch already has things like sin, cos, and tan which I only barely even know so it's definitely not an issue about accessibility!
- TheLogFather
-
Scratcher
1000+ posts
General Exponent Operator
Here's a project with a custom power-of block that gives way more than you're likely to get from a built-in Scratch exponent block:

http://scratch.mit.edu/projects/16871883
If you want to understand why that's the case, then take a look at this topic: http://scratch.mit.edu/discuss/topic/82240/

http://scratch.mit.edu/projects/16871883
If you want to understand why that's the case, then take a look at this topic: http://scratch.mit.edu/discuss/topic/82240/
- Iditaroid
-
Scratcher
500+ posts
General Exponent Operator
Here's a project with a custom power-of block that gives way more than you're likely to get from a built-in Scratch exponent block:It would still be nice to have a built in reporter, for anybody who doesn't know about your block
http://scratch.mit.edu/projects/16871883
If you want to understand why that's the case, then take a look at this topic: http://scratch.mit.edu/discuss/topic/82240/
- mumu245
-
Scratcher
1000+ posts
General Exponent Operator
bump. Why did they delete the old power block topic?
- medians
-
Scratcher
1000+ posts
General Exponent Operator
bump. Why did they delete the old power block topic?It got merged with a topic from 2013
https://scratch.mit.edu/discuss/topic/2860/
Last edited by medians (March 28, 2023 13:27:54)
- Discussion Forums
- » Suggestions
-
» General Exponent Operator







