aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorjohn haque <j.eh@mchsi.com>2012-02-19 08:44:00 -0600
committerjohn haque <j.eh@mchsi.com>2012-02-19 08:44:00 -0600
commitcb17a712ea65f6510e0000374cce4efbf4ffb902 (patch)
tree3b82a95607edb6adba2bbd49934851c6547d7703 /profile.c
parent0221eb79f43f4ef5c8d74759679a501607936d19 (diff)
downloadegawk-cb17a712ea65f6510e0000374cce4efbf4ffb902.tar.gz
egawk-cb17a712ea65f6510e0000374cce4efbf4ffb902.tar.bz2
egawk-cb17a712ea65f6510e0000374cce4efbf4ffb902.zip
Finish builtins for MPFR.
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/profile.c b/profile.c
index 6d9db06e..bc93d2cd 100644
--- a/profile.c
+++ b/profile.c
@@ -228,7 +228,7 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int in_for_header)
if (m == Nnull_string) /* optional return or exit value; don't print 0 or "" */
pp_push(pc->opcode, m->stptr, DONT_FREE);
else if ((m->flags & NUMBER) != 0)
- pp_push(pc->opcode, pp_number(m->numbr), CAN_FREE);
+ pp_push(pc->opcode, pp_number(m), CAN_FREE);
else {
str = pp_string(m->stptr, m->stlen, '"');
if ((m->flags & INTLSTR) != 0) {
@@ -341,7 +341,7 @@ cleanup:
&& is_binary(t1->type)) /* (a - b) * 1 */
pp_parenthesize(t1);
if ((m->flags & NUMBER) != 0)
- tmp = pp_number(m->numbr);
+ tmp = pp_number(m);
else
tmp = pp_string(m->stptr, m->stlen, '"');
str = pp_concat(t1->pp_str, op2str(pc->opcode), tmp);
@@ -1202,13 +1202,18 @@ pp_string(const char *in_str, size_t len, int delim)
/* pp_number --- pretty format a number */
char *
-pp_number(AWKNUM d)
+pp_number(NODE *n)
{
#define PP_PRECISION 6
char *str;
emalloc(str, char *, PP_PRECISION + 10, "pp_number");
- sprintf(str, "%0.*g", PP_PRECISION, d);
+#ifdef HAVE_MPFR
+ if (n->flags & MPFN)
+ mpfr_sprintf(str, "%0.*R*g", PP_PRECISION, RND_MODE, n->mpfr_numbr);
+ else
+#endif
+ sprintf(str, "%0.*g", PP_PRECISION, n->numbr);
return str;
#undef PP_PRECISION
}
@@ -1219,7 +1224,7 @@ char *
pp_node(NODE *n)
{
if ((n->flags & NUMBER) != 0)
- return pp_number(n->numbr);
+ return pp_number(n);
return pp_string(n->stptr, n->stlen, '"');
}