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
)
Public Shared Function mpq_out_str (
stream As ptr(Of FILE),
base As Integer,
op As mpq_t
) As size_t
public:
static size_t mpq_out_str(
ptr<FILE>^ stream,
int base,
mpq_t^ op
)
static member mpq_out_str :
stream : ptr<FILE> *
base : int *
op : mpq_t -> size_t
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_tReturn 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
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_ui(op, 123, 456U);
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "w");
Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) == 7);
fclose(stream.Value.Value);
string result = System.IO.File.ReadAllText(pathname);
Assert.IsTrue(result == "123/456");
System.IO.File.Delete(pathname);
gmp_lib.mpq_clear(op);
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_ui(op, 123, 456UI)
Dim pathname As String = System.IO.Path.GetTempFileName()
Dim stream As New ptr(Of FILE)()
_wfopen_s(stream.Value.Value, pathname, "w")
Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) = 7)
fclose(stream.Value.Value)
Dim result As String = System.IO.File.ReadAllText(pathname)
Assert.IsTrue(result = "123/456")
System.IO.File.Delete(pathname)
gmp_lib.mpq_clear(op)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also