The INT_ and FRAC_ Functions

These functions return the integer and the fraction parts of a variable value, respectively.

It is important to note the relationship between these two functions and the special GPP2 variable formats. INT_ and FRAC_ work on the actual value of numeric expressions, ignoring any variable format information. This may lead to confusion in some cases, if variable formats are ignored.

For instance, assume the variable VAR has the value 2.9999, but its format only allows 2 decimal digits for the fraction part. Sending VAR to output will print the string "3.00". When compared to other variables, VAR will behave as if it has the value 3.00 (see discussion on numeric expression comparison later in this document).

However, INT_ and FRAC_ ignore the variable format. INT_(VAR) will return 2, and FRAC_(VAR) will return 0.9999. In most cases, this is indeed the desired result.

If the GPP2 developer needs to integer and fractional values of a variable while taking into account the variable format, then the following methods can be used:

Examples

VAR = 2.9999;

IPART = INT_(VAR);                  Set IPART to 2

FPART = FRAC_(VAR);                 Set FPART to 0.9999

IPART = INT_(FORMATTED_NUM(VAR));   Set IPART to 3, VAR stays 2.9999

FPART = FRAC_(FORMATTED_NUM(VAR));  Set FPART to 0, VAR stays 2.9999

VAR = FORMATTED_NUM (VAR);          Change VAR to 3.0000

IPART = INT_(VAR);                  Set IPART to 3

FPART = FRAC_(VAR);                 Set FPART to 0

 

Some functionality may be dependent on the product package. Contact your Reseller if you require a license.