Skip to content
← Back to Community
THE BEST CALCULATOR ON REPL.IT *not clickbait*
Profile icon
henryeth

Finally, this took SO MUCH effort. FINALLY IT WORKS.

I present to the repl.it community:
The best calculator I have ever seen on repl.it (so the title could potentially have been clickbait unintentionally, I have not been around for that long...). Following a trio of connected calculators:

This excels them all in all areas. The closest one is Valdez's C++ one but this is far smaller and more efficient, as well as supporting a couple more operators. Do your worst - if you do find a bug, please PLEASE let me know in the comments, I really want this flawless. It will be harder to abuse than Valdez's (I saw what you community did to that comment section) because it will should ignore any invalid characters or valid characters in invalid positions. However, obviously, integer limit is still a problem :braces himself for upcoming abuse of calculator:. Any questions or suggestions (preferably questions) please write them in the comments.

P.S: Please work calculator PLEASE.

Thank you all so much this is by far the most cycles I have ever had!

Voters
Profile icon
maxina
Profile icon
JWZ6
Profile icon
nro2collaborate
Profile icon
CodeChaos58
Profile icon
XanthusPettitt
Profile icon
SimerLol
Profile icon
LegendaryWolf
Profile icon
AxolotlBot
Profile icon
coderdude666
Profile icon
ch1ck3n
Comments
hotnewtop
Profile icon
KnightsOfAzgard

Overall nice calculator.
However, I have found an error in your calculator

@henryeth
- it cannot handle imaginary numbers (3 + 2i^2 etc.). However, imaginary numbers are a key area in algebra, so this can be called a major error.

Screenshot 2021-02-01 at 20.00.12

Another graphical problem (an extra dot in the end):

Screenshot 2021-02-01 at 20.06.35

It can also be improved by adding equation solvers with variables, like the online calculator https://www.symbolab.com/ of wolfram alpha.

Profile icon
henryeth

@KnightsOfAzgard
This calculator isn't meant to do algebra at all. The second dot is a period but yes it can be confusing I will remove it.

Profile icon
KnightsOfAzgard

@henryeth
Well, it wouldn't exactly be the best calculator on repl.it then... no offense...

Profile icon
henryeth

@KnightsOfAzgard
I said it was the best calculator on repl.it that I have seen. First, notice the lack of the word "algebra"

print("calculator" == "algebra calculator") >>> False

and second, note the "that I have seen". Even excluding the second point as it is kind of cheaty, try and find me a better calculator that matches the first point on repl.it, or, even better, make one yourself. I would be quite happy to be educated on the matter...

Profile icon
KnightsOfAzgard

@henryeth
'Calculator' may not equal 'Algebra Calculator', but 'Algebra calculator' is a 'calculator' so I suggest you make that clear.

As for finding a better calculator, I take you up on that challenge. emilian1000000's calculator (https://repl.it/@emilian1000000/Mega-Calculator) can be seen as better because of the average command as well as calculations on '<' and '>'.

Profile icon
henryeth

@KnightsOfAzgard
yes and that one is error-proof, ignores invalid characters and handles calculations that are more than "[number][operator][number]"! Oh hang on... it does none of those things

Profile icon
WILLIAMBAEWER

@henryeth
gotem

Profile icon
henryeth

@WILLIAMBAEWER
:D pretty much

Profile icon
Baconman321

@KnightsOfAzgard
If algebra is so important, why don't you go make it yourself?

It's going to be really hard, as you will have to parse the variables as well as other concepts in algebra.

Expect no less than 500 lines of code for something as complicated than that...

Profile icon
henryeth

@Baconman321
FeEl ThE bUrN

Profile icon
Coder100

is it really a good calculator without making a programming language?

@KnightsOfAzgard

Profile icon
Coder100

hm that one isn't working very well at all

image

@KnightsOfAzgard

Profile icon
henryeth

@Coder100
That one is terrible and only works for 2 numbers and one operation.

Profile icon
henryeth

@KnightsOfAzgard
@WILLIAMBAEW
@Baconman321
@Coder100
new version out now! Do more testing :mechanical laugh:

Profile icon
Baconman321

@henryeth
What's new?

Profile icon
henryeth

@Baconman321
A few new operators atm (will be more), smaller and more efficient system, handling for multi-character unary operators coming soon.

Profile icon
Baconman321

@henryeth
Don't forget scientific notation!

1e+10 is the same as 10000000000.

Profile icon
henryeth

@Baconman321
Python has that integrated already i don't need to do it.

Profile icon
Baconman321

@henryeth
doesn't work for me tho

Profile icon
CoderKid365

@henryeth
cool project

Profile icon
henryeth

@Baconman321
idk how python actually use it tbh but it should pop it in for big and small numbers I think

Profile icon
Baconman321

@henryeth
no I mean add support for parsing scientific exponents.

Profile icon
henryeth

@Baconman321
I can't be bothered

Profile icon
henryeth

@Baconman321
Actually on second thoughts, I think I may

Profile icon
enterCheesyNameHere

@Baconman321
representing variables in variables is hard.

Profile icon
applicationUFO

Not Clickbait

Totally clickbait
Profile icon
FlaminHotValdez

I saw what you community did to that comment section

I love this community so much.

Profile icon
SkullScript

It also doesn't seem to run negative numbers.

Profile icon
SkullScript

It seems that parentheses don't work.

image

Profile icon
tarboldz

@ShadowHoonter
Well you can write:

9*(12)
The answer is 108.0

It works for me.

Profile icon
Kudos

Nice calculator. If I was doing this I would just eval() it 😁

Profile icon
henryeth

@Kudos
:D I agree:

try: print(f"\nThe answer is {eval(input("Enter an expression:\n"))}.) except NameError: print("Ntr a reel xpresun u ideot.")

best calculator ever.

Profile icon
FlaminHotValdez

@Kudos
...The whole point of this is to make a calculator that doesn't do eval and isn't "Input the operator" "Input one number" "Input another number"

also to beat mine. yes I'm salty
Profile icon
henryeth

@FlaminHotValdez
there is some element of truth in that last bit... alas I admit it

Profile icon
FlaminHotValdez
Profile icon
[deleted]

@Kudos
LOLL

Profile icon
henryeth

@randomguy222
@Kudos
new version out now!

Profile icon
[deleted]

@henryeth
why ping tho

Profile icon
[deleted]

@henryeth
welp, looks like you fixed the order of operators

good job!

Profile icon
TravisRaney
Profile icon
TravisRaney
Profile icon
[deleted]
Profile icon
FlaminHotValdez

@Kudos

You: "If I was doing this I would just eval() it
Also you: makes a legitimate calculator without using eval()

Profile icon
Kudos

@FlaminHotValdez

🤣 Well I didn't want to be an
@AJK4
because it would bring no value to the community.

Profile icon
FlaminHotValdez

@Kudos
ouch roasted

Profile icon
[deleted]

finally, you got a ton of cycles

@henryeth
! And the code is sooooooooo complicated that....(what is the append thing over there? what are - char, and other crazy stuff?)

Profile icon
Whippingdot

The code is sooooo simple(not to be mean)

@CaptinNeo

Profile icon
henryeth

@Whippingdot
agreed. Simple but effective

Profile icon
X24

@CaptinNeo
Append just adds something to the end of a list

Profile icon
henryeth

@X24
ikr

Profile icon
JBloves27
Profile icon
FlaminHotValdez

@henryeth
damn I'm salty it's so much easier to do in python because of the lambdas. I challenge you to make a version of this without lambdas!

Profile icon
henryeth

@FlaminHotValdez
It would be exactly the same - just bigger. It would just be replaced by a bunch if statements in the place where it calls the lambdas. I won't because it is pointless and, as you say, you are being salty :D.

Profile icon
FlaminHotValdez

@henryeth
lol yeah at least I admit it though xD. Truth be told though I probably wouldn't be able to do it in Python at all because I'm bad at it because I couldn't find a method to do it w/o stacks.

Profile icon
henryeth

@FlaminHotValdez
Just study the code you'll figure it out. I am (spoiler alert) working on a second version with a different, simpler, method.

Profile icon
FlaminHotValdez

@henryeth
what the beep how is it possible to be simpler

Profile icon
henryeth

@FlaminHotValdez
probs not really "simpler" but more "slightly longer yet more readable and using more straightforward concepts".

Profile icon
henryeth

@FlaminHotValdez
Out now - turns out it is simpler as well as the last things I listed.

Profile icon
henryeth

@CaptinNeo
@Whippingdot
@X24
new version now out feel free to comment on this one too...

Profile icon
X24

@henryeth
I didn't critique anything, just told the guy what append means...

This is injustice!!!

Profile icon
henryeth

@X24
"InJuStIcE" fixed

Profile icon
X24
Profile icon
TravisRaney
Profile icon
SilvermoonCat

@henryeth
nice I suggest making a while loop though so that I can keep using without having to rerun, everything else looks good :D

Profile icon
henryeth

@SilvermoonCat
that is done now in the new version (check it out still on this post)

Profile icon
[deleted]

lmfao

image

Profile icon
TomMalone

SIR 66X0 IS NOT 660

Profile icon
Smart0ne

I typed in 2+2/2x2 and it said the answer is 2.090909090909091.

Profile icon
BananaJellyfish

i got infinity!
image

Profile icon
BD103

On Valdez's Calculator:
Screenshot 2021-02-02 at 08.54.53

On your calculator:
Screenshot 2021-02-02 at 08.54.09

Quoting Coder100, "ah yes, math".

(No hate, ngl. I could never do this without eval()!)

Profile icon
FlaminHotValdez

@BD103
then you are bad. Use exec()

Profile icon
SkullScript

I don't know why, but % don't work, it doesn't say invalid input, it will break.
image

Profile icon
henryeth

@ShadowHoonter
it did that with all operations if you had operation followed by nothing at the end - fixed now.

Profile icon
[deleted]

BUG


Nice Calculator 😎
But...there is a bug.

Screenshot 2021-02-01 130852

Profile icon
henryeth

@XThacker
FINALLY fixed that took too long... like almost an hour probs...

Profile icon
BobTheTomatoPie

now this is impressive python coding

Profile icon
henryeth

@BobTheTomatoPie
wooooow big names are coming tysm

Profile icon
BobTheTomatoPie

np you deserve it! I would not be able to do this in python even back when I used to use it, I was worried to click on this cause i thought it would be another eval statement, but I was very wrong, this is just awesome

@henryeth

Profile icon
henryeth

@BobTheTomatoPie
LoL I can imagine that, someone making a post with this title and the start of this description, and upvoting it with 25 bots. And the code is just:

print(eval(input("Nter th xpreson")))
Profile icon
BobTheTomatoPie

yea lol, even CC did that once

@henryeth

Profile icon
FlaminHotValdez

@BobTheTomatoPie
Which CC? CyanCoding or CodingCactus?

Profile icon
BobTheTomatoPie

coding cactus

@FlaminHotValdez

Profile icon
henryeth

@BobTheTomatoPie
I finished the second version and it is now on this post.

Profile icon
BobTheTomatoPie

wow, keep it up dude!

@henryeth

Profile icon
henryeth
Profile icon
ColePete

really good, minor suggestion, make it a loop to keep going like my calculator.

Profile icon
henryeth

@ColePete
have done, and that feature is still in the second version that is now out.

Profile icon
TravisRaney
Profile icon
ColePete

@TravisRaney
hi, i guess

Profile icon
TravisRaney

@ColePete
how are you?

Profile icon
ColePete

@TravisRaney
good you?

Profile icon
TravisRaney

@ColePete
just making my movie story season 1 and needing help though, I got it in my team

Profile icon
ColePete

@TravisRaney
ill help if you want

Profile icon
TravisRaney
Profile icon
XanthusPettitt

hi, im currently making a calculator that does, well everything and I could use some more help

Profile icon
BenCavanaugh

this should equal 1 or 16???
image

Profile icon
minishxp

You can't use variables :trololololo:

Profile icon
BenCavanaugh

image :(

Profile icon
henryeth

@BenCavanaugh
Think about it, did you genuinely expect that to work?

Profile icon
BenCavanaugh
Profile icon
Kudos

Does this using the shunting-yard algorithm? It certainly looks so.

Profile icon
Soccer135246

CANNOT HANDLE SQUARE ROOTS!

Profile icon
WILLIAMBAEWER

Screenshot 2021-02-08 at 12.25.44 PM it didnt work >:0

@henryeth

Profile icon
tarboldz

Put -69*69/420
The answer should be negative, returns POSITIVE

Put 4^-0.5
The nnswer should be 0.5. Instead returns the number if the exponent were POSITIVE (this is, 0.5), returning TWO.

You shouldn´t be SO POSITIVE with your calculator, SIR HENRY.

Profile icon
InvisibleOne

Or, you could just like do this: print(eval(input("Enter you expression: "))) since python can do math

Profile icon
RhinoRunner

@InvisibleOne
True, but statements like that can backfire.
Plugging in a user input to eval without making sure it is an equation first can let people read/write/create files, which is very bad.
If you inspect the code here, you can see how it won't run the eval if it's not an equation.

Profile icon
zplusfour

image

i tried to do quik mafs

Profile icon
ComicBro

You should make a ans option, so you can use your past answer as a number

Profile icon
TravisRaney
Profile icon
RishabTirupath1

One thing that could be improved on is floating-point math. It is hard for base-2 computers to do simple things like add 0.1 and 0.2, but you could try a workaround, like multiplying the float until it is an int.
Screenshot 2021-02-03 at 12.40.41 PM

Profile icon
jagnar

when you are using this (For example it says 5 plus 5 = 55) Could you please fix this.

Profile icon
dogsledding

@jagnar
use the actual symbols for the equation (+,/,*,^, etc)