Examples with Functions

If there are functions in an expression, evaluate any arguments to functions, then the functions using the order of operation for any arguments:

Equation Explanation
System.Math.Sqrt(3 ^ 2 + 4 ^ 2) Sqrt finds the square root
System.Math.Sqrt(9 + 4 ^ 2) ^ raises to a power
System.Math.Sqrt(9 + 16) parenthesis first
System.Math.Sqrt(25)  
5 (The hypotenuse of a right triangle!)
   
System.Math.Round(System.Math.PI)*5 Replace value of constant
System.Math.Round(3.14159)*5 functions first
3 * 5 multiplication before addition
15  
   
System.Math.Max(8, (3 + 4)) * System.Math.Min(System.Math.Sqrt(16), 3 ^ 2)  
System.Math.Max(8,7) * System.Math.Min(System.Math.Sqrt(16), 3 ^ 2) function 1st
8 * System.Math.Min(System.Math.Sqrt(16), 3 ^ 2) function 1st
8 * System.Math.Min(4, 3 ^ 2) eval. arg.
8 * System.Math.Min(4, 9) function 1st
8 *4  
32  

The functions round, min (minimum) and max (maximum) do exactly what you would expect.

Follow through each example and make sure you understand how to get the answer.


INDEX, Arithmetic Operations, Modulus Operator, Order of Operations, Functions, Algebra to Code
Next lesson: Visual Basic Variables

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Functions