Consultor Eletrônico



Kbase P173233: 4GL/ABL: Rounding occurs with explicitly defined 0 DECIMALS attribute
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/03/2011
Status: Unverified

SYMPTOM(s):

4GL/ABL: Rounding occurs with explicitly defined 0 DECIMALS attribute

Contrary to documentation, if the DECIMALS attribute of a field is explicitly set to ZERO, the AVM rounds off any source assigned to BUFFER-VALUE to the specified number of decimal places before completing the assignment.

The online and other documentation, incorrectly state the following in the description of the DECIMALS attribute:

"...If the value of DECIMALS is nonzero, the AVM rounds off any source that you assign to BUFFER-VALUE to the specified number of decimal places before completing the assignment. Otherwise, the assignment executes without rounding off the source value..."

This statement implies that no rounding occurs if the value of DECIMALS is ZERO. This is not correct because rounding occurs if the DECIMALS attribute of a field is explicitly set to ZERO.

Contrary to documentation, the decimal field value in the following example is rounded to zero decimal places:

DEFINE TEMP-TABLE ttExplicit
FIELD dField AS DECIMAL DECIMALS 0.
CREATE ttExplicit.
ttExplicit.dField = 123.4567890.
MESSAGE
"ttExplicit.dField is ROUNDED to 0 decimals: " ttExplicit.dField "~n"
VIEW-AS ALERT-BOX INFO BUTTONS OK.

Bug# OE00200212

FIX:

This is a documentation bug because if a field's DECIMALS attribute is explicitly defined as any valid non-negative integer value, including the ZERO value, the AVM rounds off any source that you assign to BUFFER-VALUE to the specified number of decimal places before completing the assignment. If a ZERO DECIMALS attribute is desired without rounding, do not explicitly set the DECIMALS attribute of that field to ZERO. For example, removing the explicit definition of the ZERO DECIMALS attribute in the above code snippet prevents the rounding of the field to ZERO decimal places:

DEFINE TEMP-TABLE ttExplicit
FIELD dField AS DECIMAL.
CREATE ttExplicit.
ttExplicit.dField = 123.4567890.
MESSAGE
"ttExplicit.dField is NOT ROUNDED to 0 decimals: " ttExplicit.dField "~n"
VIEW-AS ALERT-BOX INFO BUTTONS OK.