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)
Syntaxpublic static int mpfr_snprintf(
char_ptr buf,
size_t n,
string template,
params Object[] arguments
)
Public Shared Function mpfr_snprintf (
buf As char_ptr,
n As size_t,
template As String,
ParamArray arguments As Object()
) As Integer
public:
static int mpfr_snprintf(
char_ptr buf,
size_t n,
String^ template,
... array<Object^>^ arguments
)
static member mpfr_snprintf :
buf : char_ptr *
n : size_t *
template : string *
arguments : Object[] -> int
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:
Int32Return 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
char_ptr str = new char_ptr(".................................................");
mpfr_t r = "12345e6";
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);
Dim str As char_ptr = New char_ptr(".................................................")
Dim r As mpfr_t = "12345e6"
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)
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