Click or drag to resize
gmp_libmpz_inp_raw Method
Input from stdio stream stream in the format written by mpz_out_raw, and put the result 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_raw(
	mpz_t rop,
	ptr<FILE> stream
)

Parameters

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

Return Value

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

This routine can read the output from mpz_out_raw also from GMP 1, in spite of changes necessary for compatibility between 32-bit and 64-bit machines.

Examples
// Create, initialize, and set the value of op to 123456.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 123456U);

// Write op to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");
Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7);
fclose(stream.Value.Value);

// Read op from the temporary file, and assert that the number of bytes read is 6.
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) == 7);
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