NUMBER

Synopsis

HELP:   Convert numbers (local character set required)
TYPE:   OBJECT
SYNTAX: NUMBER(FORMAT='str',LOCALE='str',MINIMUM='str',MAXIMUM='str',MININCL,MAXINCL,IGNREST,BASE=num/BIN/B02/OCT/B08/DEC/B10/HEX/B16)

Description

This object activates number conversion for a string. If string data containing a number is written to the application memory, it can be transformed to a different representation supported by the runtime environment. Allowed minimum and maximum values (range check) and the target string format can be specified.

The number conversion requires the string to be in the local character set. Character conversion is activated for it. The string may contain leading whitespace. Trailing whitespace or non-convertible characters result in an error unless the IGNREST flag is set. You can use the whitespace handling (WHITESPACE=NUMBER) of the character conversion object as preparation for this conversion.

The format string of the object can, for example, be used to ensure that a number starts with a digit, has two fractional digits, has a sign and so on. The object was mainly designed to convert numbers from XML elements to a display representation for COBOL on mainframe systems. If you need the numbers in a different representation (BCD or two's complement number) for calculations, then you must use the integer or float converter. The use of this object can result in a loss of accuracy. The integer and float converters use an internal number representation without any loss of accuracy.

For integers (u,i,d,x,X), you can specify the base for parsing the data. Default is base 10 for decimal. Floating point numbers (f,g,G,e,E) are always parsed with base 10 and the parameter is ignored.

The range check is based on decimal string values for the maximum and the minimum. The conversion is identical with the data using IGNREST and a base of 10, to make it comparable for integers and floating point numbers.

Arguments