https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125615
--- Comment #1 from Peeter Joot <peeterjoot at protonmail dot com> ---
tested on trunk too:
ubuntu:/home/peeterjoot/tmp> cat > 125615.cob
* gcobol bug reproducer: result of a floating-point COMPUTE is not
rounded.
*
* COMPUTE with a COMP-1 (binary floating-point) operand is a
floating-point
* arithmetic operation. Per IBM Enterprise COBOL, the result of a
* floating-point operation is ALWAYS rounded, regardless of the ROUNDED
phrase
* (Language Reference SC27-8713-04, "ROUNDED phrase", p.302).
*
* 70.95 * float(0.10) ~= 7.0950001 -> rounded to V99 = 7.10
*
* Observed (gcobol 15.2.0): RESULT= 7.09 (truncated -- WRONG)
* Expected (IBM LR): RESULT= 7.10
*
* The edited receiver SHOW (PIC ZZZ9.99) isolates the stored value from
any
* numeric-DISPLAY de-editing differences; edited-picture MOVE formats
identically.
IDENTIFICATION DIVISION.
PROGRAM-ID. FLTROUND.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SUBTOTAL PIC S9(9)V99 COMP-3 VALUE 70.95.
01 RATE COMP-1 VALUE 0.10.
01 RESULT PIC S9(9)V99 COMP-3 VALUE 0.
01 SHOW PIC ZZZ9.99.
PROCEDURE DIVISION.
COMPUTE RESULT = SUBTOTAL * RATE
MOVE RESULT TO SHOW
DISPLAY "RESULT=" SHOW
STOP RUN.
ubuntu:/home/peeterjoot/tmp> gcobol 125615.cob
ubuntu:/home/peeterjoot/tmp> ./a.out
RESULT= 7.09
ubuntu:/home/peeterjoot/tmp> gcobol --version
gcobol (GCC) 17.0.0 20260604 (experimental)
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.