Data Management Capabilities > Managing Configurable Products > Developing Advanced Selection Logic for Configurable Modules > Basic Steps for Defining Advanced Selection > Using Numeric Operators and Functions in Advanced Logic
  
Using Numeric Operators and Functions in Advanced Logic
Parameters can be defined for several different types. This section provides examples for using operators and functions on numeric parameters in advanced logic.
Operators for Numeric Parameters
Parameters may be defined for Integer or Real numeric types. While these types correspond to the Windchill type definitions to which the parameter can be mapped, these are internally mapped to the Java primitive types of long and double, respectively, enabling their use in any valid Java expression as long and double variables.
The expressions can be defined from:
The Expression field of a parameter defining an actual or default value of the parameter. For additional information on use of expressions in parameters, see Information Tab of the Edit Parameter Window.
A constraint of type Expression requires the expression to evaluate to a Boolean. For additional information on constraint types of expressions, see Expression Editor.
Expressions can also be used in advanced case table. For additional information on advanced case tables, see Case Table Editor.
Arithmetic Operators
Arithmetic operators can be used with numeric parameters in expressions. These include the binary addition (+), subtraction (-), multiplication (*), and division (/) operators. For example, the following are the examples of expression constraints:
2 * a – 3 * b == c / d + e / 3
A == 2.5 * B / C – D / 7.5
Single entry or unary operators - and + can also be used (+A is equivalent to A).
A == -B + 2 * C
D = +A – (-C)
The modulo (%) operator can be used to compute the remainder from the division of the first argument by the second argument:
A == B % 7
Relational Operators
Relational operators are used for comparing numeric sub-expressions in expression constraints that must evaluate to Boolean. These include the following operators:
equal to (==)
greater than (>)
less than (<)
greater than or equal to (>=)
less than or equal to (<=)
not equal (!=)
* 
The "equal to" operator must be written as “==”, and not as “=”.
When the left or right side of the expression with the “==” operator contains a single expression, then the expression is treated as an assignment (=). For example, in the following expression constraints:
A == 2 * B + 3 * C
B / 4 - C / 3 == A
Once the values of the parameters B and C are known, then the value of the parameter A will be computed according to the formulae. In the above examples, parameter A should be defined as a non-input parameter, so that its value is computed by the formula rather than entered by the user and then computed by the formula. This also means that the input order is important where B and C are defined prior to the appearance of A. If defined in any other order where parameter A is assigned its value before the parameters B and C, then the expression is treated as a Boolean expression where the value of the parameter A is compared with the value of the formula evaluated based on the values of B and C.
* 
When both sides contain more than a single parameter, all parameters must be known before the expression constraints can be evaluated.
Referencing Methods or Expression Fragments for Numeric Parameters in Functions
Numeric parameters can also be used as arguments in OOTB, standard Java, and user-defined functions. The following sections provide alternatives for referencing a method or an expression fragment.
In the examples below, consider D_1, D_2, D_3, D_4, D_5, and D_6 as Real (Java double) parameters while P_1, P_2, P_3, and P_4 as Integer (Java long) parameters. Additionally, GeomFunctions is the name of the user-defined class, from the package ext.geom, containing geometric functions.
Using the Full Class Path to the Method
The fully-qualified name (<package path>.<class name>.<method name>) can be used to specify the function passing the parameters as arguments. The following examples illustrate this approach:
D_1 == java.lang.Math.cos(D_2) + java.lang.Math.sin(D_3)
P_1 == java.lang.StrictMath.addExact(P_2, P_3)
D_4 == ext.geom.GeomFunctions.area(D_5, D_6)
Using the Import Declarations
The classes to be imported can be specified in the WT_HOME/codebase/com/ptc/wpcfg/exparser/LookUpService.properties file as follows:
exparser.import.1=java.lang.Math
exparser.import.2=java.lang.StrictMath
exparser.import.3=ext.geom.GeomFunctions
When the above import declarations are used, the package path can be omitted when specifying the function in the expressions:
D_1 == Math.exp(D_2)
P_1 == StrictMath.round(D_3)
D_3 == ext.geom.GeomFunctions.volume(D_4, D_5, D_6)
Using the Static Import Declarations
Static import declarations can first be specified in the WT_HOME/codebase/com/ptc/wpcfg/exparser/LookUpService.properties file as follows:
exparser.static.import.1=java.lang.Math
exparser.static.import.2=ext.geom.GeomFunctions
Both the package path and the class name can be omitted, leaving only the method name, when specifying the function in the expression when using static import declarations:
D_1 == exp(D_2)
P_1 == round(D_3)
D_3 == ext.geom.GeomFunctions.volume(D_4, D_5, D_6)
If a method with the same name exists in multiple classes registered in the static imports, an exception error is displayed. For example, java.lang.Math and java.lang.StrictMath have many method names in common. Registering both classes as static imports will lead to error conditions when using such common methods in formulae.
Using Abbreviations (Aliases) for Methods
Mapping between an abbreviation for a method and the full path to the method can be defined in the WT_HOME/codebase/com/ptc/wpcfg/exparser/LookUpService.properties file as follows:
exparser.abbreviation.1=SURFACE_AREA=ext.geom.GeomFunctions.area
exparser.abbreviation.2=ARC_TAN=java.lang.StrictMath.atan
Once the mapping between an abbreviation for a method and its full path are defined, you can use these aliases to access the function in expression:
D_1 == ARC_TAN(D_2)
D_3 == SURFACE_AREA(D_4, D_5)
This technique is useful if you want to redefine a method from a Java class to be the same as the name of a function in a different application such as Microsoft Excel. When setting the ato.expression.rendering.context=com.ptc.wpcfg.logic.XLSExpressionRenderingContext property in the WT_HOME/wt.properties file, then the system adds appropriate aliases to provide access to most numeric, text, and logical functions by the names used in Microsoft Excel application. The numeric functions include ABS, ACOS, ASIN, ATAN, CEILING, COS, DEGREES, FLOOR, INT, LN, LOG, MAX, MIN, MOD, POWER, RADIANS, ROUND, ROUNDDOWN, ROUNDUP, SIN, SQRT, TAN, ACOSH, ASINH, ATANH, COMBIN, COSH, EXP, FACT, LOG10, SIGN, SINH, TANH.
Using Macros
While an abbreviation provides an aliase for the full function path of a single function, a macro is an alias for an expression fragment. It is useful when an expression fragment is used repeatedly in multiple expression. Import, static import, and abbreviation declaration are resolved on-the-fly when an expression is parsed. Macro fragments are first substituted for macros in the expression, and then the expression is parsed. As other parser properties, macro mappings are defined in the WT_HOME/codebase/com/ptc/wpcfg/exparser/LookUpService.properties file as follows:
exparser.macro.1=AREA=SURFACE_AREA(D_2, D_3)
exparser.macro.2=SUM=java.lang.StrictMath.addExact(P_2, P_3)
Then, you can use the macros in the following expressions:
D_1 == AREA + 10.2
P_1 == SUM + P_4