HP aC++/HP C A.06.20 Release Notes
if (s == 0) {
fprintf(stderr, "FAILURE: on input from %s\n", ifilename);
fclose(inp);
fclose(outp);
exit(EXIT_FAILURE);
}
if (s == EOF) break;
}
else if (encoding == bid) {
r = (int) fread(&be, sizeof(_Binaryencoding64), 1, inp);
if (r != 1) break;
m = _decodebinary64(be); // decode bid
}
else /* encoding == dpd */ {
r = (int) fread(&de, sizeof(_Decimalencoding64), 1, inp);
if (r != 1) break;
m = _decodedecimal64(de); // decode dpd
}
// compute hours billed
fe_dec_setround(FE_DEC_UPWARD);
h = m / 60;
h = quantized64(h, onert); // round to tenths
// compute billing amount
fe_dec_setround(FE_DEC_TONEARESTFROMZERO);
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);
New Features in Version A.06.20 13