Convert number to absolute value using VISION:Results

Document ID : KB000024382
Last Modified Date : 14/02/2018
Show Technical Document Details

To generate the absolute value of a numeric field to be compatible which character edit patterns, use the COMBINE BITS function.

For example:

Dataname is defined as POSNEG 3 NU

A value of POSNEG is read in as hex F0F1D2', which is a negative 12. If moved to a character field, this would display as '01K'.

What we want is to manipulate the field to hex'F0F1F2', so it displays as '012'.

You can't just multiply the field by -1 because the input data from another record may already be positive.

However, if you use COMBINE BITS where the first parameter is positive 0 (x'F0') defined for the length of your dataname, and logically 'OR' it with your dataname, you will always get the absolute value of your data.

In our example, because POSNEG is 3 bytes long we pad with 2 bytes of 0's and use this command:


This performs a OR on the 2 parameters:

     0000 0000 0000 0000 1111 0000 < x'0000F0'
     1111 0000 1111 0001 1101 0010 < x'F0F1D2'
     1111 0000 1111 0001 1111 0010 < x'F0F1F2'

This achieves the desired results of converting POSNEG to display as '012' which can be successfully moved into a character edit pattern.

For more information please see the section on COMBINE BITS in Chapter 10 of the VISION:Results Reference Guide.