HP aC++/HP C A.06.20 Release Notes
const char * ofilename = "biller.out"; // output file
const enum { ascii, bid, dpd } encoding = ascii; // input encoding
const _Decimal64 rate = 149.95DD; // hourly billing rate
#define __STDC_WANT_DEC_FP__
#include <stdio.h>
#include <std.lib.h>
#include <math.h>
#include <fenv.h>
#include <strtodec.h>
#include <assert.h>
#pragma STDC FENV_ACCESS ON
int main() {
unsigned int n; // number of inputs
_Decimal64 m; // number of minutes
_Decimal64 h; // number of hours
_Decimal64 b; // amount billed
_Decimal64 sumM, sumH, sumB; // sums
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);
12 What’s New in This Version