calculator
-
hi every body I want to make profetional calculator for complex operation such as to calculate this statement A+B(f*g-r)/A+B .. and somthing like that how can i do that??
-
hi every body I want to make profetional calculator for complex operation such as to calculate this statement A+B(f*g-r)/A+B .. and somthing like that how can i do that??
the exile wrote:
how can i do that??
Do you know we've a wonderful article repository? [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
By learning how statements and equations (and something like that) work :) Where do you want to start?
I are troll :)
-
thanks I know many thing about statement and stack and some thing about priorities and about prefix and postfix ..etc just I need some helps like idea and some codes
-
the exile wrote:
how can i do that??
Do you know we've a wonderful article repository? [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]...but....but....but....those articles do not do this statement A+B(f*g-r)/A+B :-D
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
...but....but....but....those articles do not do this statement A+B(f*g-r)/A+B :-D
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
The articles were just to fool him, why parsing when you may use javascript? :laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
The articles were just to fool him, why parsing when you may use javascript? :laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
hi every body I want to make profetional calculator for complex operation such as to calculate this statement A+B(f*g-r)/A+B .. and somthing like that how can i do that??
I'm not much of a programmer, but I'd start by modelling the data items as structs - one element for the real, the other for the imaginary part - then overload the operators to define complex functions. For instance,
struct Complex
{
public double Re, Im;
public Complex(double Re, double Im)
{
this.Re = Re;
this.Im = Im;
}
public Complex(Complex X)
{
Re = B.Re;
Im = B.Im;
}
public static Complex operator + (Complex A, Complex B)
{
Complex result = new Complex(A);
result.Re += B.Re;
result.Im += B.Im;
}
}This defines a struct with two parts called Complex, with real and imaginary parts called Re and Im, respectively. Re and Im are declared as type double. Two constructors are declared, one being initialized with separate values, the other by a type Complex value. The last bit overloads the '+' operator to return a Complex sum of two Complex variables. You can add other operators to the mix by writing the code to implement them. Although structs do not have methods, operator overloads (which look just like methods) work on structs as well as classes. In your calculator application I'd define buttons to click for each overloaded operator, something like what Microsoft has done with the built in Windows Calculator utility. By the way, I didn't write or test the above - I modified an example in a book I'm studying to fit your situation. You might want to pick up a copy and read it; "Professional C# 2005 with .Net 3.0" by Wrox Press. It's quite thorough and very readable.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
-
hi every body I want to make profetional calculator for complex operation such as to calculate this statement A+B(f*g-r)/A+B .. and somthing like that how can i do that??
Here's how I would do this: 1. Make a binary tree. Leaf nodes stand for your variables (A, B, f, g...). Interior nodes stand for an operation on the values of the interior node's two sons. 2. Go through your statement and put all tokens into a list of leaf nodes. (The operations will eventually be transferred to interior nodes.) 3. Find the range of nodes where the parentheses are most deeply nested. 4. If you have the pattern [left parenthesis] [variable] [right parenthesis], delete the two parentheses nodes. (The variable could also be an interior node.) 5. In this deeply-nested region, replace the pattern [variable] [high-precedence-operation] [variable] with an interior node for the operation, with the two variables as sons. (The variables could also be other interior nodes.) 6. Repeat Step 5 for the low-precedence operations. You should now be able to apply Step 4 on the remaining interior node left in the parentheses. 7. To evaluate the expression, do a post-order traversal on the binary tree, getting the variable values for leaf nodes, and applying the operation to the two values for interior nodes. The result of the evaluation will be left in your root node. I find this approach simpler than the recursive algorithms.
modified on Friday, March 27, 2009 10:10 AM