Results 1 to 2 of 2

Math Help - SciCalculator.com

  1. #1
    Newbie
    Joined
    Sep 2009
    Posts
    3

    SciCalculator.com

    Hi all,

    I know I'm new here and I guess it's kind of rude asking this on my first post .. but the title is just too tempting.

    Basically, I'm the creator of www.scicalculator.com and would love to have some feedback about it. I've done extensive testing on it, however, I can't help feeling that there are a couple of errors running around.

    Now to introduce myself (yeah the interesting part..): Well I'm from Malta, Europe (tiny island in the Mediterranean), love Maths, have an A level and O level etc etc and am currently studying Engineering at University

    Guess that's enough for my first post

    Cheers
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Sep 2009
    Posts
    79
    Welcome to the forum . If you don't mind me asking, what did you get in your A-Level Maths, and what parts did you find the hardest?

    Now, on topic. Just skimming through the JavaScript I can see it's kind of messy. For example:

    Code:
    if (val == "sqrt" || val == "sin" || val == "sin-1" || val == "cos" || val == "cos-1" || val == "tan" || val == "tan-1" || val == "log" || val == "ln") {
    			if ((type[count-1] == 0 && count  > 0) || (count == 0)) {
    					
    				if (val == "sqrt") {
    					mode = 6;
    				} else if (val == "sin") {
    					mode = 7;
    				} else if (val == "sin-1") {
    					mode = 8;
    				} else if (val == "cos") {
    					mode = 9;
    				} else if (val == "cos-1") {
    					mode = 10;
    				} else if (val == "tan") {
    					mode = 11;
    				} else if (val == "tan-1") {
    					mode = 12;
    				} else if (val == "log") {
    					mode = 13;
    				} else if (val == "ln") {
    					mode = 14;
    				}
    				
    			} else {
    				err = 2;
    			}		
    		}
    That can easily be achieved using the switch statement . Or of course, if you really want to be extravagant rewrite the whole inner if statement using ternary xD . It would be a lot shorter, but probably not as efficient.
    Follow Math Help Forum on Facebook and Google+

Search Tags


/mathhelpforum @mathhelpforum