NEW BEST CALCULATOR ON REPL.IT
** 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: | Mine | Heneryeth's | FlaminHotValdez's |
---|---|---|---|
Addition | yes | yes | yes |
Subtraction | yes | yes | yes |
Multiplication /w * | yes | yes | yes |
Multiplication /w x | yes | no | no |
Division | yes | yes | yes |
Exponents | yes | yes | yes |
** for exponents too | yes | no | no |
Modulus | yes | yes | no |
Unary operators | yes | yes (but no use) | no |
Negative numbers | yes | no | no |
Multiplication by parenthesis | yes | no | no |
Factorials | yes | yes | no |
Scientific notation | yes | no | no |
Square roots ((2^2)s returns sqrt of 2^2 ) | yes | no | no |
Use calculator more than 1 time per run | yes | yes | no |
Built in generally fast language | yes | no | yes |
Lots of colors! | yes | no | no |
Algebra | no | no | no |
Fast startup times | yes | yes | no |
Greater than or equal to | yes | no | no |
Less than or equal to | yes | no | no |
Less than | yes | no | no |
Greater than | yes | no | no |
Equal to | yes | no | no |
No floating point inaccuracies | yes (as I'm aware of) | no | yes |
Decimals | yes | yes | yes |
Exclude the 0 in floats without occasional side effects (like 1+.9 instead of 1+0.9 | yes | no | no |
Error handling | yes | no | no |
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
Fine I concede defeat >:(
@FlaminHotValdez
HURRAH!
HURRAH!
THE KING'S SUCCESSOR FINALLY REIGNS SUPREME!
@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.
@FlaminHotValdez @AJK4 Hehe, I know him personally, nothing new.
@Kudos ah ok
@Kudos tell him that his work is just spam if statements
Oof xd @FlaminHotValdez
It looks AMAZING! I'm usually good at errors and bugs and I couldn't find any, great job!
this was one year ago i don't think i'm coming back to it
@Kudos OK lol still an awesome calculator
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...-_-
@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.
@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.
@FlaminHotValdez
𤣠true
@BenCavanaugh
I acknowledge that's the wrong answer, but how in the world does that expression equal 9.8? Google says it is 10.
@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
I thought 5 modulo 25 is 5???
It looks like you're doing division where there's a modulo operator...
@BenCavanaugh % means modulus or remainder, not divide.
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
;)
@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.
@Kudos Well, first, what do others think?
Is that a good order to go in?
I just made a small change to the algorithm, exponents now solve correctly. Didn't have to do anything excessive.
@Kudos Cool, good to hear that it wasn't hard either.
Really nice calculator!
@JBloves27
Thanks :)
I think I have caught this in the middle of testing...
@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
Actually ever mind... I meant to enter 2*100^1000
so I got the wrong output.. nvm
YYYEEESSS I FOUND SMTH MINE DOES AND URS DOESN'T. Mine ignores illegal characters and urs raises errors for them I mean c'mon...
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.
fml I make a post titled "Actual good calculator" and now there are like 2 more best calculator on replit wannabes. :'(
@FlaminHotValdez wannabes?
@FlaminHotValdez
I just googled that acronym and I didn't get a pretty result..
@Kudos Sowwy
@FlaminHotValdez Begging doesn't work eh
this is the reason why replit needs to have CARGO and not RUSTC
smh
@Coder100
Heh. I could have used cargo by running
cargo init
in the terminal and changed the run command tocargo run
but I'm a masochist by nature ;)