Re: Add mpz_inp_str to mini-gmp

2016-07-06 Thread Torbjörn Granlund
Austyn Krutsinger writes: Where does it make the most sense to check an input string coming from a file stream? I think we just read in the stream into a buffer skipping spaces and tabs then stop reading the string on the End Of File (for file streams) or a newline

Re: Add mpz_inp_str to mini-gmp

2016-07-06 Thread Austyn Krutsinger
Where does it make the most sense to check an input string coming from a file stream? I think we just read in the stream into a buffer skipping spaces and tabs then stop reading the string on the End Of File (for file streams) or a newline '\n' (for stdin). This way the only duplicate code is the

Re: Add mpz_inp_str to mini-gmp

2016-07-06 Thread Torbjörn Granlund
How about simply doing something like this: mpz_inp_str (...) { 1. check base, ungetc proper digit for (...) { c = fgetc (...) d = convert_to_digit_value(c, base) if non-digit break mpz_mul_ui (x, x, base) mpz_add_ui (x, x, d) } } I haven't

Re: Add mpz_inp_str to mini-gmp

2016-07-06 Thread Austyn Krutsinger
On Wed, Jul 6, 2016 at 1:41 PM, Niels Möller wrote: > Austyn Krutsinger writes: > > > I am not sure if there was a reason FILE streams were not implemented > > before, but if there is I'd be interested in hearing why. > > mpz_out_str is included in

Re: Add mpz_inp_str to mini-gmp

2016-07-06 Thread Niels Möller
Austyn Krutsinger writes: > I am not sure if there was a reason FILE streams were not implemented > before, but if there is I'd be interested in hearing why. mpz_out_str is included in mini-gmp, so it would make sense to also include the companion function mpz_inp_str.

Add mpz_inp_str to mini-gmp

2016-07-06 Thread Austyn Krutsinger
I appreciate all of the effort that the community has put into complementing the gmp library with mini-gmp. I was using mini-gmp a couple days ago and wanted to read in a number from a FILE stream and noticed that the mpz_inp_str function wasn't available in mini-gmp, so I added it. I'd ask that