HP aC++/HP C A.06.25 Release Notes

Table Of Contents
b = rate * h;
b = quantized64(b, twort); // round to hundredths
// restore decimal rounding mode to default
fe_dec_setround(FE_DEC_TONEAREST);
// print billing amount to file
fprintf(outp, "%Da\n", b);
// update sums
sumM += m;
sumH += h;
sumB += b;
} // main loop
// close files
fclose(inp);
fclose(outp);
// confirm expected quantum in sums
assert(samequantumd64(sumH, onert));
assert(samequantumd64(sumB, twort));
// print summary
printf("SUMMARY:\n");
printf(" number of calls = %d\n", n);
printf(" total minutes = %Da\n", sumM);
printf(" total hours billed = %Da\n", sumH);
printf(" total amount billed = %Da\n", sumB);
return 0;
}
Notes:
The quantize functions do the work of rounding to the desired number of places
to the right of the decimal point. They return the value of their first argument
represented with the quantum exponent of their second argument, rounding if
necessary.
Mixing decimal FP and integer operands, as in the expression m / 60, is allowed.
However, the expression m / 60.0, which mixes decimal and binary FP, would
cause an error.
On the HP-UX implementation, BID data could be read directly into the decimal
FP variable m, without the need of decoding. However, that code would not be
portable to systems that use DPD encoding for their decimal FP types.
Restoring the default rounding has no effect in this program, except perhaps if the
ASCII input had more than 16 decimal digits, but doing so is a good programming
practice.
24 What’s New in This Version