Click or drag to resize
gmp_libgmp_sprintf Method
Form a null-terminated string in buf.

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 int gmp_sprintf(
	char_ptr buf,
	string fmt,
	params Object[] args
)

Parameters

buf
Type: Math.Gmp.Nativechar_ptr
The string to print to.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, excluding the terminating null.
Remarks

No overlap is permitted between the space at buf and the string fmt.

These functions are not recommended, since there’s no protection against exceeding the space available at buf.

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

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Print to string.
Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.free(str);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
See Also