This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-24 12:49:42

roger-
Scratcher
Registered: 2010-02-13
Posts: 100+

Exponent block WITHOUT REPEATED MULIPLICATION

I've seen many people who want to have a ( )^( ) block in scratch. a few people tried to make this block, but all of the examples I have seen use repeated multiplication, so they don't work with decimal exponents. I, a simple scratcher, who knows almost nothing about squeak or smalltalk, have found a way to make an exponent reporter block without using repeated multiplication.

this is how I did it:

Code:

computeExponent: t1 raisedTo: t2 
    | t3 |
    t3 _ t1 raisedTo: t2.
    ^ t3

open the browser, go to scratchObjects/scriptableScratchMorph/other ops.  copy and paste this into the box below. then press alt s to save.

then, go to scratchObjects/scriptableScratchMorph and click the class button below.
then go to scratchObjects/scriptableScratchMorph/block specs/block specs and copy and paste this into the block specs after you see ('%n / %n' #r #/ #- #-) in the block specs:

Code:

 ('%n ^ %n' #r #computeExponent:raisedTo: #- #-)

after you pasted it, press alt s to save.
close the browser and click on the operators tab. you will see a new block that will allow you to use exponents, and even allow you to use decimal exponents

to save this permanently, shift-r-click and select save screen for end user, and select yes.


WARNING: like all block hacks, this does not work online

Last edited by roger- (2010-07-24 12:51:24)


Food is Fat. Fat is power.
        I am almighty.

Offline

 

#2 2010-07-24 22:27:52

roger-
Scratcher
Registered: 2010-02-13
Posts: 100+

Re: Exponent block WITHOUT REPEATED MULIPLICATION


Food is Fat. Fat is power.
        I am almighty.

Offline

 

#3 2010-07-25 09:22:12

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

um, there's an easier method:

Code:

computeExponent: base raisedTo: exponent
     ^ base raisedTo: exponent

Last edited by ScratchReallyROCKS (2010-07-25 09:22:23)


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#4 2010-07-25 10:27:59

climber59
Scratcher
Registered: 2009-12-15
Posts: 100+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

You can also do ( {10^} of ( (exponent) * ( ( {log} of (base) ) )


Check out my projects if you have a chance.

Offline

 

#5 2010-07-25 11:43:15

roger-
Scratcher
Registered: 2010-02-13
Posts: 100+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

ScratchReallyROCKS wrote:

um, there's an easier method:

Code:

computeExponent: base raisedTo: exponent
     ^ base raisedTo: exponent

*facepalm*

see, I don't know that much about squeak.


Food is Fat. Fat is power.
        I am almighty.

Offline

 

#6 2010-08-20 18:46:34

ydoc5212
Scratcher
Registered: 2010-08-20
Posts: 2

Re: Exponent block WITHOUT REPEATED MULIPLICATION

climber59 wrote:

You can also do ( {10^} of ( (exponent) * ( ( {log} of (base) ) )

What exactly IS "base"? is it the second exponent? probably not. *sigh*


[blocks]<when green flag clicked>[/blocks]
[blocks]<forever>[/blocks]
act confused

Offline

 

#7 2010-08-21 05:37:35

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

http://i34.tinypic.com/vgk5g8.jpg

Offline

 

#8 2010-08-21 05:49:07

developdood
Scratcher
Registered: 2009-04-16
Posts: 63

Re: Exponent block WITHOUT REPEATED MULIPLICATION

In my mod, Theblocksmod, it uses this method, but I didn't copy it from this.


Have a look at some of my games. I made a cool physics game called "Physics Marble Cannon" which is really cool. I let anyone remix any of my projects without permission or credit necessary.

Offline

 

#9 2010-08-21 07:11:47

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

Bingo uses it since 1.0.0...
maybe you might want to try with just the block spec
('%n ^ %n'       r       raisedTo: - -)
not sure if that will work though because i didnt use it like that

Offline

 

#10 2012-05-09 18:04:13

ZacIsCool
Scratcher
Registered: 2012-02-24
Posts: 30

Re: Exponent block WITHOUT REPEATED MULIPLICATION

all of these return error for me! ;(

Offline

 

#11 2012-05-09 22:05:36

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

ZacIsCool wrote:

all of these return error for me! ;(

1. Don't necro 2 year old posts.

2. Pay attention to said user above you.


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#12 2012-05-10 11:12:24

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

bbbeb wrote:

ZacIsCool wrote:

all of these return error for me! ;(

1. Don't necro 2 year old posts.

2. Pay attention to said user above you.

Actually:
1. It's fine to necropost something if a user is having a problem (less topics need to be created) or has a solution to an unanswered post. It's only bad if it's just spamming. Which his post isn't.

2. I don't see how LS97 is saying that none of the code given wouldn't work. I think s/he was referring to their own code.

ZaclsCool: Could you provide some more information on how you are trying to do this?

Last edited by Magnie (2012-05-10 11:13:34)

Offline

 

#13 2012-05-10 11:16:39

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

Magnie wrote:

bbbeb wrote:

ZacIsCool wrote:

all of these return error for me! ;(

1. Don't necro 2 year old posts.

2. Pay attention to said user above you.

Actually:
1. It's fine to necropost something if a user is having a problem (less topics need to be created) or has a solution to an unanswered post. It's only bad if it's just spamming. Which his post isn't.

2. I don't see how LS97 is saying that none of the code given wouldn't work. I think s/he was referring to their own code.

ZaclsCool: Could you provide some more information on how you are trying to do this?

2. Yes, LS97 (he) was referring to his own code.
In fact, now that I know more Squeak, I can confirm that it's completely wrong  smile

Offline

 

#14 2012-11-10 15:03:23

SuperJedi224
Scratcher
Registered: 2010-12-22
Posts: 23

Re: Exponent block WITHOUT REPEATED MULIPLICATION

There used to be an official exponent block iirc. Whatever happened to it?


http://internetometer.com/image/30818.png

Offline

 

#15 2012-11-10 16:09:19

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

No, there never was one.


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#16 2012-11-10 16:40:31

SuperJedi224
Scratcher
Registered: 2010-12-22
Posts: 23

Re: Exponent block WITHOUT REPEATED MULIPLICATION

Okay then.

Last edited by SuperJedi224 (2012-11-10 16:44:06)


http://internetometer.com/image/30818.png

Offline

 

#17 2012-11-10 17:10:17

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Exponent block WITHOUT REPEATED MULIPLICATION

Well, in the functions block, there's a 10^ and a e^, if that's what you're referring to, SuperJedi.


Be nice, I'm an old lady  wink

Offline

 

Board footer