Discuss Scratch

Bura082
Scratcher
42 posts

We need More operation blocks!

<iframe src="https://scratch.mit.edu/projects/1202041641/embed“ allowtransparency=”true“ width=”485“ height=”402“ frameborder=”0“ scrolling=”no" allowfullscreen></iframe>
(() ^ ())
We need more operation
kahyreedre
Scratcher
37 posts

We need More operation blocks!

these are two different ways to make exponents in scratch, remember to replace the “num” with an actual number

set [value v] to [num]
set [past value v] to (value)
set [to the power of v] to [num]
repeat ((to the power of) - (1))
set [value v] to ((value) * (past value))
end
set [value v] to ((value) * <not <<(value) = (past value)> and <(to the power of) = (0)>>>)

or

 set [value v] to [num]
set [past value v] to (value)
set [to the power of v] to [num]
if <(to the power of) = (0)> then
set [value v] to (0)
else
repeat ((to the power of) - (1))
set [value v] to ((value) * (past value))
end

Last edited by kahyreedre (July 28, 2025 02:11:17)

dspace1015
Scratcher
17 posts

We need More operation blocks!

Or alternatively for decimal values:
(as a^b)

set [a v] to [number1]
set [b v] to [number2]
set [value v] to ([e ^ v] of ((b)*([ln v] of ([abs v] of (a)::operators)::operators)))::operators)
if <(a)<(0)> then
if < ((b) mod (2))=(1)> then
set [value v] to (() - (value))
else
if < not<((b) mod (2)) = (0)>> then
set [value v] to [NaN]
end
end
end

or even simpler, if you don't need to worry about negative numbers:
set [a v] to [number1]
set [b v] to [number2]
set [value v] to ([e ^ v] of ((b)*([ln v] of (a)))::operators)
It would be awesome to have it in the form of
 
((a) ^ (b)::operators)
But you can achieve the same thing with this method.

Last edited by dspace1015 (Nov. 2, 2025 20:33:09)

kahyreedre
Scratcher
37 posts

We need More operation blocks!

dspace1015 wrote:

It would be awesome to have it in the form of
 
((a) ^ (b))
I'll try to make it in the form of a
 
(())



Last edited by kahyreedre (July 28, 2025 15:13:44)

TlOriginalScratcher3
Scratcher
11 posts

We need More operation blocks!

Bura082 wrote:

<iframe src="https://scratch.mit.edu/projects/1202041641/embed“ allowtransparency=”true“ width=”485“ height=”402“ frameborder=”0“ scrolling=”no" allowfullscreen></iframe>
(() ^ ())
We need more operation

try my project out it's a exponent calculator
https://scratch.mit.edu/projects/1213515496/

(add features if you want)

Powered by DjangoBB