Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to do exponents?
- djollieboy11
-
Scratcher
14 posts
How to do exponents?
I am working on how to make exponents, and I found that their is no exponent block. would somebody be able to help me do this? This is my code so far:
after all of that, I have an ask script that asks the player what the answer is, but I can't add that because the way I entered this didn't have the blocks.
also, this took forever to make, since I had to type this out and learn this new language that is only in the forums.
when green flag clicked
forever
set [number one] to (pick random (3) to (10)
set [number two] to (pick random (3) to (10)
set [exponent] to (pick random (0) to (5)
set [sum of exponents and second number] to [number two]
if <not <<[exponent] = [0]> or <[exponent] = [1]>>> then
repeat (exponent)
set [sum of exponents and second number] to ((sum of exponents and second number) * (number two))
end
set [sum of exponents and second number] to ((sum of exponents and second number) / (number two))
set [sum of equation] to ((sum of exponents and second number) * (number one))
else
if <[exponent] = [0]> then
set [sum of equation] to (1)
else
if <[exponent] = [0]> then
set [sum of equation] to ((number one) * (number two))
end
end
end
end
after all of that, I have an ask script that asks the player what the answer is, but I can't add that because the way I entered this didn't have the blocks.
also, this took forever to make, since I had to type this out and learn this new language that is only in the forums.
Last edited by djollieboy11 (March 11, 2025 14:55:20)
- Cool_Dude2022
-
Scratcher
500+ posts
How to do exponents?
I am working on how to make exponents, and I found that their is no exponent block. would somebody be able to help me do this? This is my code so far:when green flag clicked
forever
set [number one] to (pick random (3) to (10)
set [number two] to (pick random) (3) to (10)
set [exponent] to (pick random) (0) to (5)
set [sum of exponents and second number] to [number two]
if <not <<[exponent] = [0]> or <[exponent] = [1]>>> then
repeat (exponent)
set [sum of exponents and second number] to ((sum of exponents and second number) * (number two))
end
set [sum of exponents and second number] to ((sum of exponents and second number) / (number two))
set [sum of equation] to ((sum of exponents and second number) * (number one))
else
if <[exponent] = [0]> then
set [sum of equation] to (1)
else
if <[exponent] = [0]> then
set [sum of equation] to ((number one) * (number two))
end
end
end
end
after all of that, I have an ask script that asks the player what the answer is, but I can't add that because the way I entered this didn't have the blocks.
also, this took forever to make, since I had to type this out and learn this new language that is only in the forums.
also sorry, I messed up a little in the code.
You mean something like this? Pretty simple to make: https://scratch.mit.edu/projects/1145491233/editor/
- NoUsername-King
-
Scratcher
100+ posts
How to do exponents?
Okay, exponents can be calculated with
([e^ v] of (([ln v] of (base)::operators) * (exponent))::operators)And root can be calculated with this
([e^ v] of (([ln v] of (base)::operators) / (root))::operators)
- djollieboy11
-
Scratcher
14 posts
How to do exponents?
Okay, thank you all for the help! I really appreciate it.
- SuperBee444
-
Scratcher
2 posts
How to do exponents?
Okay, exponents can be calculated withI hope you see this, does root mean square root, and if so, square root of what?([e^ v] of (([ln v] of (base)::operators) * (exponent))::operators)And root can be calculated with this([e^ v] of (([ln v] of (base)::operators) / (root))::operators)
- NoUsername-King
-
Scratcher
100+ posts
How to do exponents?
(#5)That can be used for any root, including a square root. A square root would look like this:Okay, exponents can be calculated withI hope you see this, does root mean square root, and if so, square root of what?([e^ v] of (([ln v] of (base)::operators) * (exponent))::operators)And root can be calculated with this([e^ v] of (([ln v] of (base)::operators) / (root))::operators)
([e^ v] of (([ln v] of (base)::operators) / [2])::operators)and a cube root would be a 3 and so on.
- Dan_0319
-
Scratcher
16 posts
How to do exponents?
Okay, exponents can be calculated withoh, theres a problem though. how do you do negative bases???([e^ v] of (([ln v] of (base)::operators) * (exponent))::operators)And root can be calculated with this([e^ v] of (([ln v] of (base)::operators) / (root))::operators)
- N8_D_GR8_1
-
Scratcher
1000+ posts
How to do exponents?
-snip-Please avoid posting on other people's topics unless you are helping them. You should create a new topic instead.
oh, theres a problem though. how do you do negative bases???
Here is a fully functional exponent function that I made:
define (x) ^ (y)
if <(x::custom) > [0]> then
set [EXPONENT: output v] to ([e ^ v] of ((y::custom) * ([ln v] of (x::custom)::operators))::operators)
else
if <(x::custom) < [0]> then
if <(y::custom) = (round (y::custom))> then
set [EXPONENT: output v] to (((1) - ((2) * ((y::custom) mod (2)))) * ([e ^ v] of ((y::custom) * ([ln v] of (() - (x::custom))::operators))::operators))
else
set [EXPONENT: output v] to [NaN]
end
else
if <(y::custom) < [0]> then
set [EXPONENT: output v] to [NaN]
else
set [EXPONENT: output v] to (() + <(y::custom) = [0]>)
end
end
end
EDIT: I had to make so many edits to find what Scratch thought was inappropriate language. Apparently “p l e a s e d o n o t p o s t…” is unsuitable language? Man, Scratch really needs to fix the filter.
Last edited by N8_D_GR8_1 (Oct. 31, 2025 14:30:04)
- dspace1015
-
Scratcher
17 posts
How to do exponents?
oh, theres a problem though. how do you do negative bases???Look at my response to this discussion if you need to do negative bases.
- Discussion Forums
- » Help with Scripts
-
» How to do exponents?






