case CTINT:
case CTSINT:
case CTUINT:
- Bprint(bout, "0x%llux\n", mpgetfix(n->val.u.xval));
+ Bprint(bout, "%B\n", n->val.u.xval);
break;
case CTBOOL:
Bprint(bout, "0x%llux\n", n->val.u.bval);
void mpatoflt(Mpflt *a, char *s);
void mpmovefltfix(Mpint *a, Mpflt *b);
void mpmovefixflt(Mpflt *a, Mpint *b);
+int Bconv(Fmt*);
/*
* mparith2.c
fmtinstall('N', Nconv); // node pointer
fmtinstall('Z', Zconv); // escaped string
fmtinstall('L', Lconv); // line number
+ fmtinstall('B', Bconv); // big numbers
lexinit();
lineno = 1;
warn("set ovf in mpatov: %s", as);
mpmovecfix(a, 0);
}
+
+int
+Bconv(Fmt *fp)
+{
+ char buf[500], *p;
+ Mpint *xval, q, r, ten;
+ int f;
+
+ xval = va_arg(fp->args, Mpint*);
+ mpmovefixfix(&q, xval);
+ f = 0;
+ if(mptestfix(&q) < 0) {
+ f = 1;
+ mpnegfix(&q);
+ }
+ mpmovecfix(&ten, 10);
+
+ p = &buf[sizeof(buf)];
+ *--p = 0;
+ for(;;) {
+ mpdivmodfixfix(&q, &r, &q, &ten);
+ *--p = mpgetfix(&r) + '0';
+ if(mptestfix(&q) <= 0)
+ break;
+ }
+ if(f)
+ *--p = '-';
+ return fmtstrcpy(fp, p);
+}
snprint(buf1, sizeof(buf1), "LITERAL-ctype=%d", n->val.ctype);
break;
case CTINT:
- snprint(buf1, sizeof(buf1), "I%lld", mpgetfix(n->val.u.xval));
- break;
case CTSINT:
- snprint(buf1, sizeof(buf1), "S%lld", mpgetfix(n->val.u.xval));
- break;
case CTUINT:
- snprint(buf1, sizeof(buf1), "U%lld", mpgetfix(n->val.u.xval));
+ snprint(buf1, sizeof(buf1), "I%B", n->val.u.xval);
break;
case CTFLT:
snprint(buf1, sizeof(buf1), "F%g", mpgetflt(n->val.u.fval));