HP aC++/HP ANSI C Release Notes (B3901-90037; A.06.26; September 2011)

const _Decimal64 onert = 0.0DD; // for rounding to tenths
const _Decimal64 twort = 0.00DD; // for rounding to hundredths
FILE *inp=NULL; // input stream
FILE *outp=NULL; // output stream
int r, s; // fread, scanf returns
_Binaryencoding64 be; // for binary-encoded (bid) input
_Decimalencoding64 de; // for decimal-encoded (dpd) input
// open input file
if (encoding == ascii)
inp = fopen(ifilename, "r");
else
inp = fopen(ifilename, "rb");
if (inp == NULL) {
fprintf(stderr, "FAILURE: could not open %s\n", ifilename);
exit(EXIT_FAILURE);
}
// open output file
outp = fopen(ofilename, "w");
if (outp == NULL) {
fprintf(stderr, "FAILURE: could not open %s\n", ofilename);
exit(EXIT_FAILURE);
}
// initialize sums
sumM = 0.DD;
sumH = 0.0DD;
sumB = 0.00DD;
// main loop
for (n=0; ; n++) {
// read a number
if (encoding == ascii) {
s = fscanf(inp, "%De", &m);
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;
New features in version A.06.20 27