Share your repls and programming experiences

← Back to all posts
NEW BEST CALCULATOR ON REPL.IT
h
Kudos (115)

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):

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!

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
Comments
hotnewtop
Coder100 (17126)


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

smh

Kudos (115)

@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 ;)

ch1ck3n (1632)

oK THIS IS THE BESt

Kudos (115)

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

Kudos (115)

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

Kudos (115)

@Coder100
NOOOOOOOOOOOOOOOOOOOO SOLViNG IT
Edit: solved

FlaminHotValdez (442)

Fine I concede defeat >:(

Kudos (115)

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

FlaminHotValdez (442)

@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.

Kudos (115)

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

Kudos (115)

@FlaminHotValdez

He sometimes gives me a laugh

FlaminHotValdez (442)

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

Whippingdot (573)

I admit it, this is godly:

NOICE

Kudos (115)

@Whippingdot
Shoutout to @math for the godliness!

henryeth (181)

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

henryeth (181)

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

Kudos (115)

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

AnishReddy3 (1)

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

FlaminHotValdez (442)

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...-_-

Kudos (115)

@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.

FlaminHotValdez (442)

@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.

BenCavanaugh (17)

no PEMDAS

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

Kudos (115)

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

BenCavanaugh (17)

@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

Kudos (115)

@BenCavanaugh

I thought 5 modulo 25 is 5???

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

FlaminHotValdez (442)

@BenCavanaugh % means modulus or remainder, not divide.

xxpertHacker (871)
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

;)

Kudos (115)

@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.

xxpertHacker (871)

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

Kudos (115)

@xxpertHacker

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

xxpertHacker (871)

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

henryeth (181)

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

Kudos (115)

@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

TalinSharma (71)

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

@Kudos

henryeth (181)

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

Kudos (115)

@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

henryeth (181)

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

Kudos (115)

@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

henryeth (181)

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.

Kudos (115)

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

henryeth (181)

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

FlaminHotValdez (442)

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

Kudos (115)

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

FlaminHotValdez (442)

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