Menu

Commit [r13091]  Maximize  Restore  History

Fix INTERVAL addition and negative results

Two faults in the year-month branch of A4GL_in_in_ops, which is where interval
arithmetic actually happens.

Addition wrote the total as a float and handed that to the parser:

SPRINTF1 (buff_3, "%f", d_i1); /* "68.000000" */
acli_interval (buff_3, 0x822);

which cannot be read as a year-month interval, so every addition of two
intervals produced 0-00. Subtraction, a few lines below, already split the
total into years and months and wrote "Y-M". Addition now does the same.

That shared formatting was itself wrong for a negative total: it wrote each
field with its own sign, so -40 months came out as "-3--4", which does not
parse either - any subtraction giving a negative result produced -0-00. The
sign belongs to the value, not to each field, and is now written once at the
front with the fields carrying the magnitude.

The day-time class was already correct; it goes through the seconds path.

The interval fidelity probe now covers subtraction, addition and a subtraction
crossing zero, in both classes.

Note that A4GL_op_ival in lib/libaubit4gl/interval.c, corrected in r13081, has
no callers - the two bugs fixed there are real but that function is dead code,
and it is not what interval arithmetic runs through. Left as it is: it is
correct now, and worth keeping that way if anything ever calls it.

mikeaubury 2026-09-05

changed /aubit4glsrc/trunk/dotnet/fidelity/endtoend/interval.4gl
changed /aubit4glsrc/trunk/lib/libaubit4gl/ops.c
/aubit4glsrc/trunk/dotnet/fidelity/endtoend/interval.4gl Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/lib/libaubit4gl/ops.c Diff Switch to side-by-side view
Loading...