Better calculator
Archives → Feature requests → Better calculator
CLOSED
The /calc has mutiple flaws:
- Only integer
- No functions like sin cos tan
- No power symbol (^)
I would like to request the coder of redstoner to change the code.
In case you are too lazy to make the code yourself, here is the code: [http://pastebin.com/sm0w9y9J]
Closed by pep
@GutenTagPolania
Did yiu write that code in the pastebin?
Average times:
Load time: 80ms
Execution time ( 1 samples, “9+9”): 3.00ms ( 3ms total) Execution time ( 10 samples, “9+9”): 0.40ms ( 4ms total) Execution time ( 100 samples, “9+9”): 0.16ms (16ms total) Execution time (1000 samples, “9+9”): 0.79ms (79ms total)
Correctness of the outputs:
Equasion | Result | Real Result | Correct? | Ex. Time |
---|---|---|---|---|
9+9 | 18 | 18 | YES | 3ms |
4^.5 | 4 | 2 | NO | 5ms |
9^9^9^9 | 0 | Inf | NO | 18ms |
i^2 | EX | -1 | NO | 14ms |
log(e,e) | EX | 1 | NO | 14ms |
sqrt(-1) | NaN | i/NaN | YES | 16ms |
sqrt(-1)^2 | 2 | 1/NaN | NO | 21ms |
sqrt(4)^2 | 0 | 4 | NO | 19ms |
asin(sin(pi)) | EX | pi | NO | 15ms |
max(4,5)^2 | 7 | 25 | NO | 17ms |
(4)^2 | 6 | 8 | NO | 4ms |
(4)^0 | 4 | 1 | NO | 3ms |
Sooo now for the question: What lead me to the assumption that ^ means “pow”? Well 9^9 gives me 81. Aka it’s supposed to mean “pow”. However in all of the above examples it was used as XOR, except in the 9^9^9^9 one where it just went like “nah m8 I’ma completely go all over the top and say dat’s 0 lmao”. You got an amazing precision of 8.3%, I guess each mathematician out there would be really pleased with that calculator. “Yeah, you gotta try 5000 times, then make a graph and look for the spike that makes up around 8% of the results, that’s most likely the correct one. Might still be wrong though.”
From that point of view: Nah m8. Try better next time.
Also, before you complain, I did remove the “math” before trying :P
And here is the code to test it for yourself to check that I didn’t make any mistakes. If the package/imports are wrong then I copied improperly cause it’s in my “test” file, which contains a shitload more so I had to cut it out. The package is correct for me though and the imports are being managed by eclipse for me, therefor that couldn’t have caused the wrong results :)
fixed em except the imaginary number
[http://pastebin.com/R9K5P17A]
Please exploit more bugs for improvement
With the updated code: 9+9 - 18 - Correct pow(4,.5) - 2.0 - Correct pow(9,pow(9,pow(9,9))) - Infinity - Correct log(e,e) - 1.0 - Correct sqrt(-1) - NaN - Correct pow(sqrt(-1), 2) - NaN - Incorrect asin(sin(pi)) - 1.2246467991473532E-16 - (unsure, tested it on pure java and gives the same result) pow(max(4,5),2) - 25.0 - Correct pow(4,2) - 16.0 - Correct pow(4,0) - 1.0 - Correct
Entering javascript code will not work.
Complex number doesnt work. Working on factorial.
Okay, added factorial, but (x)! doesnt work, only x! (It is frikkin 4:36 AM I have to sleep)
[http://pastebin.com/cJ2diMqP]
@Logal Sorry bout that, but apprently you can just jam in a string.
Here is a log of mine using eval() to use complex():
a = complex(“1+2j”) a (1+2j) a*a (-3+4j)