gmp_libgmp_vasprintf Method |
Form a null-terminated string in a block of memory obtained from the current memory allocation function.
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_vasprintf(
ptr<char_ptr> ptr,
string fmt,
params Object[] ap
)
Public Shared Function gmp_vasprintf (
ptr As ptr(Of char_ptr),
fmt As String,
ParamArray ap As Object()
) As Integer
public:
static int gmp_vasprintf(
ptr<char_ptr>^ ptr,
String^ fmt,
... array<Object^>^ ap
)
static member gmp_vasprintf :
ptr : ptr<char_ptr> *
fmt : string *
ap : Object[] -> int
Parameters
- ptr
- Type: Math.Gmp.Nativeptrchar_ptr
- fmt
- Type: SystemString
Format string. See Formatted Output Strings. - ap
- Type: SystemObject
Arguments.
Return Value
Type:
Int32The return value is the number of characters produced, excluding the null-terminator.
Remarks
The block will be the size of the string and null-terminator. The address of the block in stored to ptr.
Unlike the C library vasprintf, gmp_vasprintf doesn’t return -1 if there’s no more memory available,
it lets the current allocation function handle that.
Examples
ptr<char_ptr> str = new ptr<char_ptr>();
mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;
Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
Assert.IsTrue(str.Value.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");
gmp_lib.free(str.Value);
gmp_lib.mpz_clear(z);
gmp_lib.mpq_clear(q);
gmp_lib.mpf_clear(f);
Dim str As New ptr(Of char_ptr)()
Dim z As mpz_t = "123456"
Dim q As mpq_t = "123/456"
Dim f As mpf_t = "12345e6"
Dim m As mp_limb_t = 123456
Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42)
Assert.IsTrue(str.Value.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100")
gmp_lib.free(str.Value)
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)
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