Click or drag to resize
mpfr_lib.mpfr_snprintf Method
Form a null-terminated string corresponding to the optional arguments under the control of the template string template, and print it in buf.

Namespace:  Math.Mpfr.Native
Assembly:  Math.Mpfr.Native (in Math.Mpfr.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static int mpfr_snprintf(
	char_ptr buf,
	size_t n,
	string template,
	params Object[] arguments
)

Parameters

buf
Type: Math.Gmp.Native.char_ptr
The output buffer.
n
Type: Math.Gmp.Native.size_t
The number of characters written to the output buffer.
template
Type: System.String
Format string. See Formatted Output Functions.
arguments
Type:System.Object[]
Arguments.

Return Value

Type: Int32
Return the number of characters that would have been written had n been sufficiently large, not counting the terminating null character, or a negative value if an error occurred.
Remarks

If n is zero, nothing is written and buf may be a null pointer, otherwise, the n - 1 first characters are written in buf and the n-th is a null character.

Examples
// Allocate unmanaged string with 50 characters.
char_ptr str = new char_ptr(".................................................");
mpfr_t r = "12345e6";

// Print to string.
Assert.IsTrue(mpfr_lib.mpfr_snprintf(str, 41, "%Re", r) == 10);
Assert.IsTrue(str.ToString() == "1.2345e+10");
Assert.IsTrue(mpfr_lib.mpfr_snprintf(str, 41, "%Rf", r) == 18);
Assert.IsTrue(str.ToString() == "12345000000.000000");
Assert.IsTrue(mpfr_lib.mpfr_snprintf(str, 41, "%Rg", r) == 10);
Assert.IsTrue(str.ToString() == "1.2345e+10");
Assert.IsTrue(mpfr_lib.mpfr_snprintf(str, 41, "%Ra", r) == 15);
Assert.IsTrue(str.ToString() == "0x2.dfd1c04p+32");
mpfr_lib.mpfr_clear(r);
gmp_lib.free(str);
See Also