Calculator With Functions

Install Java to view this project right on your browser!

user_icon Paddle2See* shared it 2 years, 11 months ago
1544 views, 7 taggers, 70 people love it, 10 remixes by 8 people, 279 downloads, in 18 galleries
Add to my favorites?
Flag as inappropriate?

Comments

You need to be logged in to post comments

Add a Comment

 
PerspectiveDesigns PerspectiveDe… 1 month, 2 weeks ago

This is very neat! The next version of my programming language(its done but not on Scratch yet) is going to be able to do this! I've already made a program thats almost as advanced as this! I don't have pi,e,phi,or ^ yet.

Paddle2See Paddle2See* 1 month, 2 weeks ago

Sounds very advanced :)

Hardmath123 Hardmath123 2 months, 2 weeks ago

You're an inspiration—I was inspired to make this: (link to project) by both this project and one by illusionist. You keep Scratching, and I'll never run out of ideas! :P

markwest markwest 3 months, 2 weeks ago

wow!

kaikaiprogrammerguy kaikaiprogram… 7 months, 3 weeks ago

WOW! I'm working on something like this, and with one script! So far it is decent, but it will eventually work up to something comparable to this.

Paddle2See Paddle2See* 7 months, 3 weeks ago

Cool! This was a real mental workout for me - getting it to work as well as it does. Fun stuff :)

(view all replies)
Ilovenatrue Ilovenatrue 11 months ago

Oh gosh...I tried reading the description but because I'm so young...it barely gives me much sense.

Paddle2See Paddle2See* 11 months ago

Sorry - this is one of my more complicated projects.

(view all replies)
freedom1 freedom1 12 months ago

wow! with those skills you'll be the perfect employe at Rush's software lab! :)

Paddle2See Paddle2See* 12 months ago

Thanks! I'm not currently looking for another employment position though :)

(view all replies)
amcerbu amcerbu 1 year ago

Great! How about user-defined functions, and function libraries? I can imagine putting in preset ones- Hero's formula, quadratic formula, regular polygon area, etc. Weird Java quirk- exponentiation returns numbers just a fraction too small. 2^3 yields 7.999999999999999997.

Paddle2See Paddle2See* 1 year ago

Ah! Thanks for clearing that up, I was wondering. As for the quirk...yeah, that's annoying. Maybe I should put in adjustable display accuracy and have it round to a given number of places.

Paddle2See Paddle2See* 1 year ago

Sure, that would be possible! What is the "Hero's forumla"? I'm not familiar with that name.

(view all replies)
santaisonfacebook santaisonface… 1 year, 1 month ago

Paddle2See*

DarthPickley DarthPickley 1 year, 2 months ago

flash player glitch: if you say 90, it returns 9. if you say sin(90), it gives something which is not 1 (also sin(pi/2) is not 1)

Paddle2See Paddle2See* 1 year, 2 months ago

Ah! It broke my project! Bummer. Well, hopefully this will be an easy fix. I'll pass it along to the development team :)

(view all replies)
DarthPickley DarthPickley 1 year, 2 months ago

its part of the glitch where it recognizes 0 as null! so it thinks 1000 = 1!

(view all replies)
DarthPickley DarthPickley 1 year, 2 months ago

oh, but sin(9*5*2) =1!

mrsrec mrsrec 1 year, 2 months ago

*Stands At The Computer For 12 Mintues Entering "5"* [5] [=5] :)

Paddle2See Paddle2See* 1 year, 2 months ago

I didn't realize there was a difference in the way that downloaded projects are named between Macs and PC's. That's interesting. I don't know the reason the [1] is put there...I always thought it was just another way to show that it is a remix.

(view all replies)
Paddle2See Paddle2See* 1 year, 2 months ago

Hmmm. I don't remember making it recognize square brackets....

(view all replies)
macweirdo macweirdo 1 year, 2 months ago

If you don't end a parenthesis, the system fails. That's because of the postfix search not finding "" in any lists. Therefore, if you see "" in that section of the program, skip thinking, output answer.

Paddle2See Paddle2See* 1 year, 2 months ago

Yeah, about your comment on Moore's law and calculators...my sons and I were discussing that. It's like they are frozen in time or something. I mean, for the same money, you can get a fully functioning computer that fits in your pocket and can make phone calls too! We figured the only reason they can keep getting those prices for such limited functionality is that they are the only devices allowed during tests.

Paddle2See Paddle2See* 1 year, 2 months ago

Go right ahead and remix and make any fixes you want...it would be great to see this taken further. I've kind of lost interest in it at the moment...more worried about doing beta testing on the Flash player so that most of my projects will work in it :)

(view all replies)
Paddle2See Paddle2See* 1 year, 2 months ago

Yeah, RPN is very cool. I always admired those people with the HP calculators that could rattle that stuff off without even thinking about it. I wonder if HP even makes RPN calculators any more?

(view all replies)
Paddle2See Paddle2See* 1 year, 2 months ago

It could use a bit of work making it more fault-tolerant, that's for sure. Thanks for the feedback.

(view all replies)
MasterShinobi MasterShinobi 1 year, 5 months ago

Hey, could you help me find a suitible script for finding square roots? You type in a number and it gives you the square root, but I can't think of a good script! If you can do this, I think you should have no problem. I hope you can help! Thanks a lot.

Paddle2See Paddle2See* 1 year, 5 months ago

There's always more to learn :)

Paddle2See Paddle2See* 1 year, 5 months ago

There's a built-in function for giving Square Roots in the Operators section...were you planing on using that? If so, it would be very easy, just use the Ask block to get the number, then use the Say (Sqrt (Answer)) for 2 seconds.

(view all replies)
Rick3137 Rick3137 1 year, 6 months ago

Top Notch. I like it.

Paddle2See Paddle2See* 1 year, 6 months ago

Thanks! It still has a few "issues" here and there. But it works for most common expressions.

2l84zwamani 2l84zwamani 1 year, 7 months ago

Cool, like the way you list the expression as well :)

bobtheroadie bobtheroadie 1 year, 7 months ago

how do you put a command line in a scratch project

Paddle2See Paddle2See* 1 year, 7 months ago

Here's a gallery which might help you get started (link to gallery)

Paddle2See Paddle2See* 1 year, 7 months ago

You use the Ask / Answer features (in the Sensing area) to get what the user wants to do and put it in a variable. Then comes the hard part...you need to figure out what the user wants and do it. There's a couple of ways to do that to. If each command is just one word, it's pretty easy. If the command can be multiple words, it gets much harder as you have to tear the variable apart to get at the words.

legolover legolover 1 year, 8 months ago

Judging by the scripts I assume you have experience in other programming languages. Do you?

rodrigocalix rodrigocalix 1 year, 8 months ago

awesome project

Paddle2See Paddle2See* 1 year, 8 months ago

Thank you rodrigocalix :)

poose poose 1 year, 9 months ago

lol this is better than school calculators cuz it gets 100/60x60 correct whether school ones say 99,97236867

WeirdF WeirdF 1 year, 9 months ago

Hi Paddle2See, would it be okay if I implemented this calculator in a project I'm making at the moment? :)

Paddle2See Paddle2See* 1 year, 9 months ago

Oh sure! All my stuff (as well as everything else on the Scratch site) is there for you to remix :)

(view all replies)
3-14159265358979323 3-14159265358… 1 year, 11 months ago

error 10^-11=1.0e11 not 1.0000000000000001e11

daccount10 daccount10 2 months, 1 week ago

Its probably just the way the computer stores fractional values (like the way you can't precisely show 1/3 in regular decimal numbers).

3-14159265358979323 3-14159265358… 1 year, 11 months ago

actually it equals 1.0e-11 it says 1.000000000000000e-11

3-14159265358979323 3-14159265358… 1 year, 11 months ago

0.2*0.2=0.04 not 0.04000000000000001 very close but 10^-15 more

LillyM101 LillyM101 2 years ago

Cool!

hamstermon hamstermon 2 years, 1 month ago

i did 55^77^99 and it = infinaty

HD123 HD123 1 year, 10 months ago

my computer calculator says it equals 6.0923102922427461214668079811849e+13266

Paddle2See Paddle2See* 2 years, 1 month ago

As far as the computer is concerned - it is! Computers can only show numbers up to a certain size (it varies by computer/operating system). That number is very big :)

hamstermon hamstermon 2 years, 1 month ago

it said 0^0 = nan and 0^-1 = infinaty

DarthPickley DarthPickley 2 years, 1 month ago

now we're finally learning about this in school... and I now am able to respect the project even more. being able to do parentheses without recursion!

Paddle2See Paddle2See* 2 years, 1 month ago

Thanks! There's usually a non-recursive approach to most problems. In this case, I'm using a stack :)

meew0 meew0 2 years, 1 month ago

It says 4/0 = Infinity and 0/0 = NaN

likegames likegames 1 year, 11 months ago

4/0 does equal infinity, knowing that no number times 0 is 4 other than infinity, but infinity is just a concept, not a number. 0/0=0, that was just a fault.

Paddle2See Paddle2See* 2 years, 1 month ago

Interesting! Neither one of those operations are defined so I'm not sure why it is giving different answers. NAN stands for Not A Number and you usually get it when you have tried to get the computer to do something not defined.

mmww mmww 2 years, 2 months ago

i have a calculator too!(link to project)

KSA KSA 2 years, 2 months ago

I love sonic but my little brother wants me to do a wrestling project it will be totally different.

KSA KSA 2 years, 2 months ago

I was wrong I hate wrestling.

KSA KSA 2 years, 2 months ago

Awesome!

KSA KSA 2 years, 2 months ago

I changed my picture to super sonic Paddle2See

(view all replies)
MonkeyJoe35 MonkeyJoe35 2 years, 2 months ago

My new project is out. Thanks for all of your help, i couldnt have done it without your Shunting yard algorithm. sadly i couldnt figure out how to optimize it the way you said with a variable, but let me know if you have any other ideas to optimize it. it is incredibly slow and would be appreciated. (link to project)

likegames likegames 2 years, 2 months ago

It says 11.53242 is twelve. When I did 9.452478567847785787344573847856347624*10^11.53242 it said 9.452478567847785787344573847856347624e12 instead of 9.452478567847785787344573847856347624e11.53242

Paddle2See Paddle2See* 2 years, 2 months ago

It must have rounded. There are limits to what Scratch (or any computer) can display :)

(view all replies)
likegames likegames 2 years, 2 months ago

99999999999999999999999999999999999^9999999999999999999999999999999999999=infinity

likegames likegames 2 years, 2 months ago

=infinity

DarthPickley DarthPickley 2 years, 3 months ago

oops

DarthPickley DarthPickley 2 years, 3 months ago

I found a huge glitch in exponents: the process fails when you raise a negative number to an exponent. the entry '-1^1' returned 'NaN'. you could probably fisx this using If Else blocks for special calculations.

DarthPickley DarthPickley 2 years, 3 months ago

I found a huge glitch in exponents: the process fails when you raise a negative number to an exponent. the entry '-1^1' returned 'NaN'. you could probably fisx this using If Else blocks for special calculations.

Paddle2See Paddle2See* 2 years, 3 months ago

Oh fudge!

DarthPickley DarthPickley 2 years, 3 months ago

you should make an abs function

sparks sparks° 2 years, 3 months ago

Dear Paddle2See, I was looking through the 1.4 source code and noticed "waterRippleRate" in filters. is there a way I can make a block with that?

Paddle2See Paddle2See* 2 years, 3 months ago

Sorry, I don't know the answer to that. I do know that there were some graphic effects that didn't make it into the production versions of Scratch. Maybe the functionality is still in Scratch. I'd ask on the Advanced Topics forum and see if anybody else knows.

(view all replies)
Connerscratcher Connerscratcher 2 years, 3 months ago

see my project, It seems to be a better way to do powers. It's called function calculator. Great project! If you so happen to want to use my way, please give me credit...

Paddle2See Paddle2See* 2 years, 3 months ago

No need to feel naive...I have no idea what level of math you have learned. Many people on this site have no idea that there even *are* such things as negative and fractional exponents - they just haven't been taught them yet :)

(view all replies)
Paddle2See Paddle2See* 2 years, 3 months ago

Thanks...I like the approach you have used, it is great if your powers are positive integers. But the approach I went with will handle negative and fractional powers so it is more flexible...although it does have slight errors :)

(view all replies)
3-14159265358979323 3-14159265358… 2 years, 3 months ago

4^2=16 NOT 15.999999999999993!

Paddle2See Paddle2See* 2 years, 3 months ago

It's close enough for me. Same issue as before, I'm using Log and Exp to compute powers and there is a small amount of error. I suppose I could put in a special routine to handle the integer cases...

(view all replies)
3-14159265358979323 3-14159265358… 2 years, 3 months ago

pi=3.1415926535 not 3...536

likegames likegames 1 year, 11 months ago

Your name should be 3-1415926535897932384626.

Paddle2See Paddle2See* 2 years, 3 months ago

But the next digit is 8 so I'm rounding the 5 to a 6. That's standard engineering practice.

(view all replies)
3-14159265358979323 3-14159265358… 2 years, 3 months ago

how about factorals(!)

Paddle2See Paddle2See* 2 years, 3 months ago

Go for it :)

3-14159265358979323 3-14159265358… 2 years, 3 months ago

why is 5^(1+2)*(4*5-10)-((4-4)+6-1)=1244.9999999999995?It"s supposed to be 1245

Paddle2See Paddle2See* 2 years, 3 months ago

I think it is a small error caused by the Log and Exp functions that are used to calculate the ^ function (which should really be a Scratch built-in)

3-14159265358979323 3-14159265358… 2 years, 3 months ago

how about rounding?

Paddle2See Paddle2See* 2 years, 3 months ago

You mean, is there a rounding function? Not at the moment...it might be a fun thing to add though :)

(view all replies)
Andrewjr98933 Andrewjr98933 2 years, 4 months ago

I've been attempting to make a calculater several times. Never got it. I looked at your scripts. Still. I will never get it D: --- Lol.

Paddle2See Paddle2See* 2 years, 4 months ago

It's probably a bit uglier than it has to be. Sorry about that. Ssaamm has a pretty cool one - I haven't looked at the scripts yet to see how it's done. (link to project)

Extremos Extremos 2 years, 4 months ago

Hi Paddle2See. There is a Scratcher named ThePCKid who is always using vulgar language. He swears alot too. I've even seen him use the f-bomb on someone's gallery! Please consider warning him about his language. I have flagged some of his comments too. Here's an example of the kinds of things that he says. (link to gallery) I am not asking you to ban him. A polite warning would be nice. Thanks.

(view all replies)
likegames likegames 1 year, 11 months ago

¿Really? (spanish keyboard, lol) ThePCKid used to be my friend...

3-14159265358979323 3-14159265358… 2 years, 3 months ago

because it's rude

(view all replies)
3-14159265358979323 3-14159265358… 2 years, 3 months ago

i flagged that comment!

(view all replies)
3-14159265358979323 3-14159265358… 2 years, 3 months ago

yes

(view all replies)
rdococ rdococ 2 years, 4 months ago

0+3^5^5^5^5^5^7887 = Infinity!

Paddle2See Paddle2See* 2 years, 4 months ago

Lol - well, that's probably pretty close!

jsbwalker jsbwalker 2 years, 4 months ago

Yes, I have a project that puts operators and numbers in separate lists then eliminates them according to BEDMAS. Right now I looks simple but it can be easily adapted to perform more advanced functions by adding an exponent process. You can find this project here (link to project) Hope you find it interesting. oh and be careful it has a large long script.

jsbwalker jsbwalker 2 years, 4 months ago

Seems much more complex than was needed to get the job done.

Paddle2See Paddle2See* 2 years, 4 months ago

Many languages offer a built-in function that will evaluate a math expression directly...Scratch doesn't have one yet :)

Paddle2See Paddle2See* 2 years, 4 months ago

Super! I'd love to see a simpler approach. Do you know one?

rdococ rdococ 2 years, 4 months ago

I have a idea: Add 'abs' fuction.

Paddle2See Paddle2See* 2 years, 4 months ago

Wouldn't be all that hard...I'm already handling the trig functions. Good idea!

MonkeyJoe35 MonkeyJoe35 2 years, 4 months ago

Hello Paddle, im back from my break from scratch. I was wondering, do you know of a way i could tweak this calculator so that when calculating, the postfix stack is not deleted? What i want is the same postfix over and over, so it would help very much to not have it get deleted in the process. I have gotten around this a bit by 'saving' the postfix into a list and then copying that into the active postfix, but i think it would be quicker another way. any ideas/help you have is great! thanks!

Paddle2See Paddle2See* 2 years, 4 months ago

Sure...you could probably do it with two additional variables. One to keep track of the current stack value and one to act as a pointer into the stack so you know how far you have worked your way through it. You would have to change the evaluation logic to use the two new variables but that wouldn't be too hard. Hope that helps :)

(view all replies)
DarthPickley DarthPickley 2 years, 4 months ago

I created a parametric function graphing project from this: (link to project)

ghostown ghostown 2 years, 5 months ago

Awesome

3-14159265358979323 3-14159265358… 2 years, 5 months ago

why does 2^2=3.999999999999999? it's supposed to be 4. close but incorrect.about 10e-15 more and it will be right.

Paddle2See Paddle2See* 2 years, 5 months ago

Wonderful account name you have there!

Paddle2See Paddle2See* 2 years, 5 months ago

I think it is slight errors in the log and/or exp functions that I am using to compute the raise to a power.

3-14159265358979323 3-14159265358… 2 years, 5 months ago

why does 2^2^2=15.9999999999999999984? It's supposed to be 16.

daccount10 daccount10 2 months, 1 week ago

Its because of the way computers store numbers. For example in base 10(normal numbers) you cannot write 1/3 exactly.

domben domben 1 year, 11 months ago

@ like games - I understand powers, just nver used them in that way. Used a bit of investigating with ma brain (@) and found out that ^ means squared (or at least in that sense) . As it seems to me that 2 squared = 4, which in turn squared = 16 ;)

rdococ rdococ 2 years, 4 months ago

I tested it, you are true. I done 2*2*2*2 which is 2^2^2.

(view all replies)
domben domben 2 years, 4 months ago

actually, 2*2*2 is 8, your thinking of 2*2*2*2

(view all replies)
Morb Morb 2 years, 5 months ago

I can't figure it out... How are you able to parse it so quickly? I'm trying to build a programming language out of Scratch, and it needs to parse a lot...

Paddle2See Paddle2See* 2 years, 5 months ago

Help yourself to anything you can use from the project, if you want.

Paddle2See Paddle2See* 2 years, 5 months ago

Well, the first thing I do is break up the line into fields and stick the fields in a list. After that, I use the "Contains" block as much as possible since it is built in to the language and very quick. It's worth the extra effort of making lists that contain allowable choices just so you can use Contains to narrow down what you are dealing with. Hope that helps :)

(view all replies)
horsegoddess horsegoddess 2 years, 5 months ago

hello this is horsegoddess with a tiny question. What differences are there between V 1.3 and 1.4?

Paddle2See Paddle2See* 2 years, 5 months ago

Quite a lot! Here's a project that discusses some of the new features that were added in 1.4 (link to project)

(view all replies)
jackrulez jackrulez 2 years, 6 months ago

Modulus? (mod)

Paddle2See Paddle2See* 2 years, 6 months ago

Mod is not in there currently...but it probably wouldn't be that hard to add it.

MonkeyJoe35 MonkeyJoe35 2 years, 6 months ago

wow. i know i liked this project a lot before.. but im trying to incorporate a calculator into one of my next projects and it is out of my grasp. i looked at your code and i cant even begin to understand it! if its alright, id like to use your calculator for my project (assuming i can understand it well enough to manipulate your code).

Paddle2See Paddle2See* 2 years, 6 months ago

Sure...that's what it's for :) I hope it works well for you. I've had some trouble importing projects that use lists into other projects though...if you have trouble, try starting with this project and importing the other one and see if that works any better.

(view all replies)
ThePCKid ThePCKid 2 years, 6 months ago

Cool! I make a GUI calculator here: (link to project) It is very simple

Carl_ Carl_ 2 years, 7 months ago

found a glitch: 1-0.9=0.09999999999..8

yambanshee yambanshee 2 years, 6 months ago

its because scratch uses floating point variables which has a habit of sometimes but rarly make a error of about 1E-10

cocoanut cocoanut 2 years, 6 months ago

Not necessarily a glitch. What it means is .099999999... repeating forever, and .099999999999... IS equivalent to .1.

(view all replies)
Please Wait...