Click or drag to resize
gmp_libmpz_out_str Method
Output op on stdio stream stream, as a string of digits in base base.

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_out_str(
	ptr<FILE> stream,
	int base,
	mpz_t op
)

Parameters

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

Return Value

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

The base argument may vary from 2 to 62 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.

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);

// Get a temporary file.
string pathname = System.IO.Path.GetTempFileName();

// Open temporary file for writing.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");

// Write op to temporary file, and assert that the number of bytes written is 6.
Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) == 6);

// Close temporary file.
fclose(stream.Value.Value);

// Assert that the content of the temporary file is "123456".
string result = System.IO.File.ReadAllText(pathname);
Assert.IsTrue(result == "123456");

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

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