diff options
author | john haque <j.eh@mchsi.com> | 2012-03-19 04:30:00 -0500 |
---|---|---|
committer | john haque <j.eh@mchsi.com> | 2012-03-19 04:30:00 -0500 |
commit | 40645cb3cb155eb59dd745af4ae0e06e729c8eb1 (patch) | |
tree | 1c24a9a6cb2ac9acc985b3f4667c7139c10c4525 /command.y | |
parent | b5431a4825e325c61f4043e4d25e47d7891c228c (diff) | |
download | egawk-40645cb3cb155eb59dd745af4ae0e06e729c8eb1.tar.gz egawk-40645cb3cb155eb59dd745af4ae0e06e729c8eb1.tar.bz2 egawk-40645cb3cb155eb59dd745af4ae0e06e729c8eb1.zip |
Add arbitrary-precision arithmetic on integers.
Diffstat (limited to 'command.y')
-rw-r--r-- | command.y | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1246,8 +1246,17 @@ err: errno = 0; #ifdef HAVE_MPFR if (do_mpfr) { - r = mpg_node(); - (void) mpfr_strtofr(r->mpg_numbr, tokstart, & lexptr, 0, RND_MODE); + int tval; + r = mpg_float(); + tval = mpfr_strtofr(r->mpg_numbr, tokstart, & lexptr, 0, RND_MODE); + IEEE_FMT(r->mpg_numbr, tval); + if (mpfr_integer_p(r->mpg_numbr)) { + /* integral value, convert to a GMP type. */ + NODE *tmp = r; + r = mpg_integer(); + mpfr_get_z(r->mpg_i, tmp->mpg_numbr, MPFR_RNDZ); + unref(tmp); + } } else #endif r = make_number(strtod(tokstart, & lexptr)); |