On 10/25/2011 7:24 PM, leif wrote:
leif wrote:
Bob Smith wrote:
I'm puzzled by the description of this function which says that the base
may vary from 2..36 and -2..-36, but then goes on to describe the
allowed chars in the string for bases 37..62.
[...]
Oh, actually the answer is simpler. The GMP documentation [1] says:
Function: int mpz_set_str (mpz_t rop, char *str, int base)
[...]
The base may vary from 2 to 62, or if base is 0, then the leading
characters are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0
for octal, or decimal otherwise.
For bases up to 36, case is ignored; upper-case and lower-case letters
have the same value. For bases 37 to 62, upper-case letter represent the
usual 10..35 while lower-case letter represent 36..61.
(The MPIR documentation of that function is identical.)
So *both* A..Z and a..z are allowed for bases up to 36, and the meaning
of a..z for bases>36 is straightforward, just as one would expect (I
think).
(The documentation of mpz_get_str() [2] is similar, except that of
course either lowercase or uppercase letters are used, or -- depending
on the base -- both at the same time, but then having different
significance.)
Btw., what documentation were you referring to? The source code doesn't
contain what you cited either.
I was reading the most recent MPIR PDF file
(http://mpir.org/mpir-2.4.0.pdf), end of section 5.4 where it says
-----------------------------------------------------------------------
char * mpz_get_str (char *str, int base, mpz t op)
Convert op to a string of digits in base /base/. The base may vary from
2 to 36 or from −2 to −36.
For /base/ in the range 2..36, digits and lower-case letters are used;
for −2..−36, digits and upper-case letters are used; for 37..62, digits,
upper-case letters, and lower-case letters (in that significance order)
are used.
-----------------------------------------------------------------------
So you can see why I was confused. Moreover, the same function in the
same section in the most recent GMP PDF file
(http://gmplib.org/gmp-man-5.0.2.pdf) contains the identical (and
incomplete) wording.
It looks like both PDF files need updating to match the documentation
you cite. Thanks for clearing up the encoding.
--
_______________________________________________________________
Bob Smith - bsm...@sudleyplace.com
http://www.sudleyplace.com - http://www.nars2000.org
--
You received this message because you are subscribed to the Google Groups
"mpir-devel" group.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mpir-devel?hl=en.