Skip to content
← Back to Community
NEW BEST CALCULATOR ON REPL.IT
Profile icon
Kudos

** NEW BEST CALCULATOR ON REPL.IT title may or may not be stolen from @henryeth **

From thought to idea to working code, I present to you a great calculator. I have been coding in the dark for many days now, to shine it upon the light!

So, you ask why it's the best calculator on Repl?

Let's compare 2 calculators including mine (thanks to a friend for making it):

image

Here's a more complete (and slightly less biased lol) version with 3 being compared:

Has:MineHeneryeth'sFlaminHotValdez's
Additionyesyesyes
Subtractionyesyesyes
Multiplication /w *yesyesyes
Multiplication /w xyesnono
Divisionyesyesyes
Exponentsyesyesyes
** for exponents tooyesnono
Modulusyesyesno
Unary operatorsyesyes (but no use)no
Negative numbersyesnono
Multiplication by parenthesisyesnono
Factorialsyesyesno
Scientific notationyesnono
Square roots ((2^2)s returns sqrt of 2^2)yesnono
Use calculator more than 1 time per runyesyesno
Built in generally fast languageyesnoyes
Lots of colors!yesnono
Algebranonono
Fast startup timesyesyesno
Greater than or equal toyesnono
Less than or equal toyesnono
Less thanyesnono
Greater thanyesnono
Equal toyesnono
No floating point inaccuraciesyes (as I'm aware of)noyes
Decimalsyesyesyes
Exclude the 0 in floats without occasional side effects (like 1+.9 instead of 1+0.9yesnono
Error handlingyesnono

Yes, you just saw error handling in my calculator's features maybe solely because I don't want people abusing this calculator
I have everything the two other calculators have (as I currently know) and more!
Here are some great pics showing off the calculator's capabilities!

image

image

image

image

image

image

image

image

image

image

Notes:

  • Inspired to do this after @henryeth made a calculator (to expand knowledge)
  • Made by converting the expression/equation to Reverse Polish Notation with the Shunting yard algorithm, which is then easily solved
  • Any inaccuracies in this post that should be corrected please tell me
  • I made a goal to not use any external dependencies other than those rust has itself, which meant lots of code.
  • Please don't look at the code it's ugly don't blame me for writing
    432 lines of bad code distributed among 13 files I already know :(
  • No hate/spam/unconstructive criticism plez
Voters
Profile icon
MattDESTROYER
Profile icon
xxpertHacker
Profile icon
programmeruser
Profile icon
JBloves27
Profile icon
Soccer135246
Profile icon
FlaminHotValdez
Profile icon
henryeth
Profile icon
LegendaryWolf
Profile icon
Whippingdot
Profile icon
ch1ck3n
Comments
hotnewtop
Profile icon
Coder100

image
this is the reason why replit needs to have CARGO and not RUSTC

smh

Profile icon
Kudos

@Coder100
Heh. I could have used cargo by running cargo init in the terminal and changed the run command to cargo run but I'm a masochist by nature ;)

Profile icon
FlaminHotValdez

Fine I concede defeat >:(

Profile icon
Kudos

@FlaminHotValdez
HURRAH!
HURRAH!
THE KING'S SUCCESSOR FINALLY REIGNS SUPREME!

Profile icon
FlaminHotValdez

@Kudos rip... But can we just take a moment to appreciate the fact that you commented on AJK4's post about how his code is literally just spam if statements and an eval() function. He denied it, I argued with him, and guess what he does? He goes and deletes the post. Srsly.

Profile icon
Kudos

@FlaminHotValdez @AJK4 Hehe, I know him personally, nothing new.

Profile icon
FlaminHotValdez

@Kudos ah ok

Profile icon
Kudos
Profile icon
FlaminHotValdez

@Kudos tell him that his work is just spam if statements

Profile icon
JBloves27
Profile icon
ch1ck3n

oK THIS IS THE BESt

Profile icon
Kudos

@ch1ck3n
The best calculator doesn't deserve an upvote? ;) gotem

Profile icon
ch1ck3n
Profile icon
Kudos

@ch1ck3n
It's the thought that counts :) (btw send that to support as an issue because that's not supposed to happen)

Profile icon
ch1ck3n

@Kudos nah it worked

Profile icon
Kudos
Profile icon
Coder100
Profile icon
Kudos

@Coder100
NOOOOOOOOOOOOOOOOOOOO SOLViNG IT
Edit: solved

image

Profile icon
Whippingdot

I admit it, this is godly:

image

NOICE

Profile icon
Kudos

@Whippingdot
Shoutout to @math for the godliness!

Profile icon
Whippingdot
Profile icon
henryeth

@Kudos When there actually is a user called math...

Profile icon
henryeth

@Kudos you literally just need to go to the history and bring it back

Profile icon
Kudos

@henryeth
I think it's fixed but there might be some bugs when I restored it.

Profile icon
DeluxeDrxps

It looks AMAZING! I'm usually good at errors and bugs and I couldn't find any, great job!

Profile icon
DaCuteRaccoon

image

Still need to fix floating point :)

Profile icon
Kudos

@DaCuteRaccoon

this was one year ago i don't think i'm coming back to it

Profile icon
DaCuteRaccoon

@Kudos OK lol still an awesome calculator

Profile icon
FlaminHotValdez

I'm aware that this is an old post but...My post does not have floating point inaccuracies, and well...the slow startup time? BLAME REPLIT

EDIT: Mine also has decimals...-_-

Profile icon
Kudos

@FlaminHotValdez
Maybe you could change the run command to execute the binary instead of compiling it every single time (what I did).

Your post does not have floating point inaccuracies, and has decimals.
But there aren't any floating point inaccuracies because the number is truncated to the first 10 digits.

Profile icon
FlaminHotValdez

@Kudos I truncate it to 10 digits because nobody really cares after that lol...we are a coding community, not NASA trying to calculate the value of pi to the millionth decimal point.

Profile icon
Kudos
Profile icon
IOP3
Profile icon
BenCavanaugh

no PEMDAS
image
should equal 9.8 if you are using PEMDAS, (parenthesis, exponents, multiplication, division, addition, subtraction.)

Profile icon
Kudos

@BenCavanaugh
I acknowledge that's the wrong answer, but how in the world does that expression equal 9.8? Google says it is 10.

Profile icon
BenCavanaugh

@Kudos google does the division first when they should put multiplication first.

5 + 5 - 5 % 5 * 5

5 + 5 - 5 % 25
5 % 25 = 0.2

5 + 5 - 0.2

10 - 0.2 = 9.8

Profile icon
Kudos

@BenCavanaugh

I thought 5 modulo 25 is 5???

It looks like you're doing division where there's a modulo operator...

Profile icon
FlaminHotValdez

@BenCavanaugh % means modulus or remainder, not divide.

Profile icon
xxpertHacker
Expression 2 ^ 3 ^ 4 -> 4096

I thought that this would be parsed as (2 ^ (3 ^ 4)), therefore it would be (2 ^ 81) and then (2417851639229258349412352)?

Otherwise, nice!

Now allow me to to type in:

f(x) = x * x f(4) 16

;)

Profile icon
Kudos

@xxpertHacker
Ah, just saw this. I'll might loop over the equation in reverse and solve the exponents backwards as a result, or do a look ahead to see if there is an exponent sign immediately following another exponent sign.

Profile icon
xxpertHacker

@Kudos Well, first, what do others think?
Is that a good order to go in?

Profile icon
Kudos

@xxpertHacker

I just made a small change to the algorithm, exponents now solve correctly. Didn't have to do anything excessive.

Profile icon
xxpertHacker

@Kudos Cool, good to hear that it wasn't hard either.

Profile icon
JBloves27

Really nice calculator!

Profile icon
Kudos

@JBloves27
Thanks :)

Profile icon
JBloves27

Np! :) @Kudos

Profile icon
henryeth

I think I have caught this in the middle of testing...

Profile icon
TalinSharma
Profile icon
Kudos

@TalinSharma
It's called scientific notation and it's used for really big numbers. I just noted that the scientific notation my calculator uses differs from what google uses
image

Profile icon
TalinSharma

Actually ever mind... I meant to enter 2*100^1000 so I got the wrong output.. nvm

@Kudos

Profile icon
henryeth

You cannot layer unary operators for example (2^2)s! and 3!! raise artificial errors.

Profile icon
Kudos

@henryeth
Yikes. You can use parenthesis for now, but I'll include that in.

Edit: Old post but I came back to this and it's fixed

Profile icon
henryeth

YYYEEESSS I FOUND SMTH MINE DOES AND URS DOESN'T. Mine ignores illegal characters and urs raises errors for them I mean c'mon...

Profile icon
Kudos

@henryeth
Lol that's fair, but [custom] errors mean that there will be less people abusing my calculator because 1n is -1, and more people will just simply be getting annoyed that they can't make an unexpected result ;) gotem

image

Profile icon
henryeth

Well played. Thank you especially for pinging me twice in the description and mentioning me on my calculator and mispelling my name once in the description. I will get this title back do not worry hehe. Maybe in Python though, the "slow" programming language.

Profile icon
Kudos

@henryeth
If you outdo me I'll re-outdo you 😁

Profile icon
henryeth

@Kudos Might need algebra for that... I wonder how long this will go on for.

Profile icon
FlaminHotValdez

fml I make a post titled "Actual good calculator" and now there are like 2 more best calculator on replit wannabes. :'(

Profile icon
henryeth
Profile icon
Kudos

@FlaminHotValdez
I just googled that acronym and I didn't get a pretty result..

Profile icon
henryeth

@Kudos umm yes, indeed

Profile icon
FlaminHotValdez

@Kudos Sowwy

Profile icon
FlaminHotValdez

Screenshot from 2021-02-16 17-49-06

Our dear community hates calculators and will spam hate comments here. Like fr just read my comment section :'(

Profile icon
Whippingdot
Profile icon
henryeth

@FlaminHotValdez Begging doesn't work eh