# An actual good calculator

There are like a BAJILLION posts on replit that are "calculators" that go like this:

Please input which operation you would like: Plus, minus, add, or divide

Please input which numbers you would like to add.

I got bored of those, and I made a calculator where you can just straight up input the expression you want to calculate. Works with +,-,*,/,^ for exponent, and parentheses! Not only that it follows order of operations too. It even has decimal capability of 10 places. Also, no eval() function.

The purpose of this post? To make a calculator where you can just enter your math expression instead of printing "Plus, minus, multiply or divide?" without using eval. ~~also to prove that stacks are useful because basically no posts on replit use stacks~~

# EDIT: Y'all are razzing on me because my calculator doesn't work for super big numbers or if you just input gibberish. But seriously there is a thing called integer limit... sigh

# UPDATE: Floor division has been added.

ah, yes, math

wait looking at your code it's more of a regular lang than a context-free lang. what's going on here

@FlaminHotValdezit doesn't fully recurse

@FlaminHotValdezfor example, you don't really care if the equation is valid, and thus you can easily have it segfault

@FlaminHotValdezthe thing is a context-free language, which math is, recurses so to have precedence

@FlaminHotValdezyou can use strings to store the number [email protected]

strings won't work because you can't do calculations with them

@FlaminHotValdezand what are you doing here?

i got the ping

@FlaminHotValdezso you respond to pings?

Me: makes good calculator.

*After* that.

Valdez: makes similarly good calculator.

Me: gets 3 upvotes.

Valdez: gets 15+ upvotes and a ton of recognition.

How I love repl.it.

*cowers behind wall*

*language*(maybe that is the reason???) so it obviously isn't any kind of a copy (the one thing I would be

**especially angry**if it was).

9^-98765 dumped it

LOL I just caused a core dump by declaring a variable x = 2 (without the type specification like int, long long int, float, etc.) and then return x to the power of x (2**2). You should really add algebraic expressions :)

You can use things like `long long int`

. Or you could not use cpp to make it.

Hi, this is really random but do you do competitive programming? I think I saw it in a comment somewhere

And failing hard

Yippee!

WBU? I think you're in Canada or something?

**International Olympiad of Informatics**(IOI) 👀.

Last year I was like bottom 6000 in Canada lol. But this year I was top 731. And next year, which will be my last year, I'm really hoping to be top 20 to get into the CCO 🙏

EDIT: If you read through that entire paragraph I apologize on behalf of your eyes.

Thanks! Good luck to you too! And yeah...USA has won 3 consecutive gold medals in the past 3 years. But I think the tides will turn...

~~benjamin qi is gone from the team mwahahahahahahahah~~

###### sadly he still writes problems

I live in India, so is there any way I can try qualifying in the IOI? The only website I found looked very ummm bad. The IOI website didn't help me as it didn't talk about the countries that participate

@FlaminHotValdezAlso, I have to live in USA to do that USACO thing right? I can't do it even though I was born there?

@FlaminHotValdezhow does python stacks work?

hey,

@flamingHotValdez, I'm making a calc of my own could you take a look at it? its not finished but I feel like it could use some tuningI'm not insulting your calculator I'm just meme-ing chill

If x = 72 then 2x = 92 😁 I luv math

hmph, for one other test it returned “inf”