Click or drag to resize
gmp_libmpz_inp_str Method
Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static size_t mpz_inp_str(
	mpz_t rop,
	ptr<FILE> stream,
	int base
)

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
stream
Type: Math.Gmp.NativeptrFILE
Pointer to file stream.
base
Type: SystemInt32
The base operand.

Return Value

Type: size_t
Return the number of bytes read, or if an error occurred, return 0.
Remarks

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.

Examples
// Create and initialize op.
mpz_t op = new mpz_t();
gmp_lib.mpz_init(op);

// Write op to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllText(pathname, "123456");

// Read op from the temporary file, and assert that the number of bytes read is 6.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpz_inp_str(op, stream, 10) == 6);
fclose(stream.Value.Value);

// Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op);
See Also