Click or drag to resize
gmp_libmpq_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 mpq_out_str(
	ptr<FILE> stream,
	int base,
	mpq_t op
)

Parameters

stream
Type: Math.Gmp.NativeptrFILE
Pointer to file stream.
base
Type: SystemInt32
The base.
op
Type: Math.Gmp.Nativempq_t
The operand rational.

Return Value

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

The base may vary from 2 to 36. Output is in the form "num/den" or if the denominator is 1 then just "num".

Examples
// Create, initialize, and set the value of op to 123/456.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_ui(op, 123, 456U);

// 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 7.
Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) == 7);

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

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

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

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