Click or drag to resize
gmp_libmpf_out_str Method
Print op to stream, as a string of digits.

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 mpf_out_str(
	ptr<FILE> stream,
	int base,
	size_t n_digits,
	mpf_t op
)

Parameters

stream
Type: Math.Gmp.NativeptrFILE
Pointer to file stream.
base
Type: SystemInt32
The base.
n_digits
Type: Math.Gmp.Nativesize_t
Maximum number fo digits to write.
op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

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

The mantissa is prefixed with an "0." and is in the given base, which may vary from 2 to 62 or from -2 to -36. An exponent is then printed, separated by an "e", or if the base is greater than 10 then by an "@". The exponent is always in decimal. The decimal point follows the current locale, on systems providing localeconv.

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.

Up to n_digits will be printed from the mantissa, except that no more digits than are accurately representable by op will be printed. n_digits can be 0 to select that accurate maximum.

Examples
// Create, initialize, and set the value of op to 123456.
mpf_t op = new mpf_t();
gmp_lib.mpf_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 10.
Assert.IsTrue(gmp_lib.mpf_out_str(stream, 10, 0, op) == 10);

// 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 == "0.123456e6");

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

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