Two bugs in the same function, both of which threw away the month part of a
year-month interval:
v1 = data_a[0] + data_a[1] / 12;
data_a is an int array, so dividing by an int truncated - every YEAR TO MONTH
value was treated as a whole number of years before the arithmetic ran. Fixed
by dividing by 12.0.
double yd, md;
int y = 0;
...
yd = floor (r1);
md = (r1 - y) * 12.0;
y is declared, initialised to zero and never assigned; the months are what is
left after the whole years, so it should have been yd. As written the month
field became the whole value times twelve.
Together these make subtraction correct where the result is positive and
smaller than the left operand. Addition, and a negative result, are still wrong
- the fault there is in how the result qualifier is encoded, which these two do
not reach. The interval fidelity probe records all three cases.