Chapter 15: Plotting Data on a Window

 

Arithmetic Symbols

The only arithmetic symbols that have changed since their inception in the 1960s are the exponentiation and logarithmic symbols. The following table shows these symbols.

Addition

intAnswer = intA + intB;

Subtraction

decAnswer = decA - decB;

Multiplication

dblAnswer = dblA * dblB;

Division

dblAnswer = dblA / dblB;

Exponentiation

dblAnswer = Math.Pow(dblA, 3.474); // dblA to the 3.474 power

Logarithms base 10

dblAnswer = Math.Log10(dblA);

Logarithms base e

dblAnswer = Math.Log(dblA);

Parentheses are used to enclose all mathematical expressions:

 double dblAnswer = (dblA / dblB) * dblC + dblD; 
Note  

You would never have a mathematical expression with a variable type declared on the right-hand side of the equation. This can never occur:

double dblAnswer6 = (double dblA2 / double dblB2) + 4.2;

In this case, both dblA2 and dblB2 must be declared before this statement.

Also, both dblA2 and dblB2 must have been filled with numbers before this statement can be executed. The Visual Studio C# compiler checks that the variables are filled before any arithmetic can be accomplished using them.

This sequence is acceptable:

double dblA2 = 4.0; double dblB2 = 3.5; double dblAnswer6 = (dblA2 / dblB2) + 4.2; // '4.2' automatically becomes a 'double'.

The conversions between the various arithmetic data types are shown in Chapter 9, Conversions between Data Types.

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net