[Win32] set_str() ignores exponent iff base > 36

Torbjorn Granlund tg at swox.com
Sun Dec 9 18:09:03 CET 2007

"Sisyphus" <sisyphus1 at optusnet.com.au> writes:

  #include <stdio.h>
  #include <gmp.h>
  int main(void) {
      int ret1, ret2;
      mpf_t x;
      printf("%s\n", gmp_version);
      ret1 = mpf_init_set_str(x, "ZXFY at -17", 62);
      ret2 = mpf_out_str(stdout, 62, 0, x);
      printf("\n%d %d\n", ret1, ret2);

This is indeed a GMP bug.  When I extended base support from 2...36 to
2...62, I failed to realize that strtol--used for converting the
exponent--does not handle bases > 36.  And I apparently failed to
extend the test suite to exercise all allowed exponents.

I think I'll fix this by converting the exponent using GMP's
functions.  It will probably also become faster on most systems.

Thanks for the bug report.  I will provide a patch within a few days.


More information about the gmp-bugs mailing list