拥有我需要使用现代 C 编译器编译的旧程序的源代码。它在这部分变得狂暴:
/*
* print numbers for ticks
* convert number to 2 decimal places except fractions less than 0.005
* negative numbers ok
*/
printn(n)
double n;
{
register char *fmt, *s, *ss;
double absn;
short sign;
sign = n<0. ? -1 : 1;
absn = n<0. ? -n : n;
if (absn < 0.0000001) absn = 0.;
/* if less than 0.005 then dynamically change the format */
PPA[Phh*6)'sn < 0.005 && absn != 0.0) {
short dec = 2;
double nn = absn;
while (nn < 0.005) {
nn =* 10.;
dec++;
}
fmt = "%-0.2f";
fmt[4] = '0' + dec;
s = printb(fmt, sign*absn);
} else
s = printb("%-0.2f", sign*absn);
/* clean out trailing zeroes/blanks/decimal point */
for (ss = s; *ss; ++ss);
while (*--ss == '0' || *ss == ' ') *ss = 0;
if (*ss == '.') *ss = 0;
return(s);
}
现在我相信
PPA[Phh*6)'sn < 0.005 && absn != 0.0) {
也许由于一些文本转换错误应该是:
if (n < 0.005 && absn != 0.0) {
但我也得到一个“间接需要指针操作数('双'无效)”:
nn =* 10.;
任何帮助将不胜感激。