Discuss Scratch

OmnipotentPotato
Scratcher
1000+ posts

Powers

20btheilmanngohr wrote:

define (Num1) ^ (Num2)
if <(Num2) > (0)> then
repeat (Num2)
set [output v] to ((output) * (Num1))
end
else
repeat ((0) - (Num2))
set [output v] to ((output) * (Num1))
end
end

Repeat something negative times?
stickfiregames
Scratcher
1000+ posts

Powers

OmnipotentPotato wrote:

20btheilmanngohr wrote:

define (Num1) ^ (Num2)
if <(Num2) > (0)> then
repeat (Num2)
set [output v] to ((output) * (Num1))
end
else
repeat ((0) - (Num2))
set [output v] to ((output) * (Num1))
end
end

Repeat something negative times?
if num2 is not greater than 0, then 0 - num2 is positive.

It still won't give the right answer though.
OmnipotentPotato
Scratcher
1000+ posts

Powers

stickfiregames wrote:

OmnipotentPotato wrote:

20btheilmanngohr wrote:

define (Num1) ^ (Num2)
if <(Num2) > (0)> then
repeat (Num2)
set [output v] to ((output) * (Num1))
end
else
repeat ((0) - (Num2))
set [output v] to ((output) * (Num1))
end
end

Repeat something negative times?
if num2 is not greater than 0, then 0 - num2 is positive.

It still won't give the right answer though.
Oh, my math teacher would be crying right now.
MegaApuTurkUltra
Scratcher
1000+ posts

Powers

define (b) ^ (p)
if<(p)=(0)>
if<(b)=(0)>
set [output v] to [undefined]
else
set [output v] to (1)
end
else
set [output v] to (1)
repeat([floor v] of ([abs v] of (p)))
set [output v] to ((output)*(b))
end
if<not<([floor v] of ([abs v] of (p)))=([abs v] of (p))>>
run nth root thingy here::custom
set [output v] to ((output)*(result of nth root thingy))
end
if<(p) < (0)>
set [output v] to ((1)/(output))
end
end
There
Zambonifofex
Scratcher
100+ posts

Powers

lalala3 wrote:

Zambonifofex wrote:

([e ^ v] of ((base) * ([ln v] of (power))))
or
([10 ^ v] of ((base) * ([log v] of (power))))
Nope. First of all, base and power should be switched. Second of all, that doesn't work with negative bases.
Derp.
((<(base) > [0]> * ([e ^ v] of (([ln v] of (base)) * (power)))) + (<(base) < [0]> * (((((power) mod (-2)) * (2)) + (1)) * ([e ^ v] of (([ln v] of ([abs v] of (base))) * (power))))))
This should work, even if it is cheaty, ugly and slow… (except for 0 ^ 0)
But yeah, I support () ^ (), but it already have been suggested multiple times…

Last edited by Zambonifofex (Nov. 12, 2014 18:58:07)

GyroscopeBill
Scratcher
500+ posts

Powers

Firedrake969 wrote:

MegaApuTurkUltra wrote:

XGamer01 wrote:

KingOfAwesome58219 wrote:

Sonickyle wrote:

OmnipotentPotato wrote:

TheHockeyist wrote:

ShamelessSnores wrote:

20btheilmanngohr wrote:

stickfiregames wrote:

Support, although it has been suggested before.
I think it should look like
(() ^ () :: operators)
it is probably more recognised than **
(+1)
Support
Support, even though it has been suggested innumerable times before.
Support.
Support. Why doesn't this exist yet?
Support

Support!
Support!
!troppuS
ʇɹoddns
TimothyLawyer
Scratcher
1000+ posts

Powers

(No Support) ^ 1



Think_Quest
New Scratcher
14 posts

Powers

20btheilmanngohr wrote:

define (Num1) ^ (Num2)
if <(Num2) > (0)> then
repeat (Num2)
set [output v] to ((output) * (Num1))
end
else
repeat ((0) - (Num2))
set [output v] to ((output) * (Num1))
end
end

sry, doesn't look like it'll work:
2 ^ -1 = 0.5
not 2*2
TheLogFather
Scratcher
1000+ posts

Powers

Think_Questsry wrote:

doesn't look like it'll work:
2 ^ -1 = 0.5
not 2*2
All that needs to fix it is an extra “set output to 1/output” after the second repeat.

Still won't work for non-integer powers, of course…

Zambonifofex's long expression is quite decent for the range in which it works (base>0 with any power, or base<0 with integer powers), though it might trip you up if you're expecting an integer when both base & power are ints.

Since that did cause an issue for some Scratchers when using the “e^ with ln( )” method (or “10^ with log( )”), that's why I wrote my general version in the way I did (plus that power-of-ten ‘fix’).

Last edited by TheLogFather (Nov. 13, 2014 17:13:28)

FIoer
New Scratcher
3 posts

Powers

Firedrake969 wrote:

MegaApuTurkUltra wrote:

XGamer01 wrote:

KingOfAwesome58219 wrote:

Sonickyle wrote:

OmnipotentPotato wrote:

TheHockeyist wrote:

ShamelessSnores wrote:

20btheilmanngohr wrote:

stickfiregames wrote:

Support, although it has been suggested before.
I think it should look like
(() ^ () :: operators)
it is probably more recognised than **
(+1)
Support
Support, even though it has been suggested innumerable times before.
Support.
Support. Why doesn't this exist yet?
Support

Support!
Support!
!troppuS
FIoer
New Scratcher
3 posts

Powers

TimothyLawyer wrote:

(No Support) ^ 1



Why don't you support?

NOOOOOOOOOOOO! 120 seconds! Why…
OmnipotentPotato
Scratcher
1000+ posts

Powers

FIoer wrote:

TimothyLawyer wrote:

(No Support) ^ 1



Why don't you support?

NOOOOOOOOOOOO! 120 seconds! Why…
Get nerdy. Anything squared is positive (sort of). So, he supports.
MegaApuTurkUltra
Scratcher
1000+ posts

Powers

OmnipotentPotato wrote:

FIoer wrote:

TimothyLawyer wrote:

(No Support) ^ 1



Why don't you support?

NOOOOOOOOOOOO! 120 seconds! Why…
Get nerdy. Anything squared is positive (sort of). So, he supports.
I'm confused. Shouldn't it be -(no support) or (no support)^(-1)?
x^1 = x for any x, so (no support)^1 = no support
gregory9
Scratcher
100+ posts

Powers

support
OmnipotentPotato
Scratcher
1000+ posts

Powers

MegaApuTurkUltra wrote:

OmnipotentPotato wrote:

FIoer wrote:

TimothyLawyer wrote:

(No Support) ^ 1



Why don't you support?

NOOOOOOOOOOOO! 120 seconds! Why…
Get nerdy. Anything squared is positive (sort of). So, he supports.
I'm confused. Shouldn't it be -(no support) or (no support)^(-1)?
x^1 = x for any x, so (no support)^1 = no support
Wait a second……. I was thinking (no support)^2

because no support = -support

-support^2 = support * support aka A lot of support.
Prinseskat
Scratcher
1000+ posts

Powers

Firedrake969 wrote:

MegaApuTurkUltra wrote:

XGamer01 wrote:

KingOfAwesome58219 wrote:

Sonickyle wrote:

OmnipotentPotato wrote:

TheHockeyist wrote:

ShamelessSnores wrote:

20btheilmanngohr wrote:

stickfiregames wrote:

Support, although it has been suggested before.
I think it should look like
(() ^ () :: operators)
it is probably more recognised than **
(+1)
Support
Support, even though it has been suggested innumerable times before.
Support.
Support. Why doesn't this exist yet?
Support

Support!
Support!
!troppuS
Joining the “Support!” chain.
RalphMath
New Scratcher
27 posts

Powers

This is one I came up with that I think handles everything:

define Raise (value) to (power)
if <((value) < [0]) and (((power) mod [1]) > [0]) > then // for real results with negative values, the powers have to be integers
set [answer v] to [ ] // imaginary result, set answer to empty
else
set [answer v] to ([e^ v] of ((power) * ([ln v] of ([abs v] of (value)))) // power * ln(value) gives ln of answer, use e^ to get answer value
if (((value) < [0]) and (((power) mod [2]) = [1])) then // check if value was negative, if so odd powers give negative answer
set [answer v] to ((answer) * [-1]) // flip sign for odd powers
end
end
Music-Maker
Scratcher
100+ posts

Powers

Support!
samanyolu
Scratcher
1000+ posts

Powers

GyroscopeBill wrote:

Firedrake969 wrote:

MegaApuTurkUltra wrote:

XGamer01 wrote:

KingOfAwesome58219 wrote:

Sonickyle wrote:

OmnipotentPotato wrote:

TheHockeyist wrote:

ShamelessSnores wrote:

20btheilmanngohr wrote:

stickfiregames wrote:

Support, although it has been suggested before.
I think it should look like
(() ^ () :: operators)
it is probably more recognised than **
(+1)
Support
Support, even though it has been suggested innumerable times before.
Support.
Support. Why doesn't this exist yet?
Support

Support!
Support!
!troppuS
ʇɹoddns
Support :3

Last edited by samanyolu (Nov. 15, 2014 08:04:17)

theonlygusti
Scratcher
1000+ posts

Powers

Please fix your post to look like this:
(()^()::operators)

Last edited by theonlygusti (Nov. 15, 2014 10:53:30)

Powered by DjangoBB