gmp_lib.mpz_init_set_str Method

GMP Native Interface for .NET

gmp_libmpz_init_set_str Method
Initialize rop and set its value like mpz_set_str.

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 mpz_init_set_str(
	mpz_t rop,
	char_ptr str,
	int base
)
Public Shared Function mpz_init_set_str ( 
	rop As mpz_t,
	str As char_ptr,
	base As Integer
) As Integer
public:
static int mpz_init_set_str(
	mpz_t^ rop, 
	char_ptr str, 
	int base
)
static member mpz_init_set_str : 
        rop : mpz_t * 
        str : char_ptr * 
        base : int -> int 

Parameters

rop
Type: Math.Gmp.Nativempz_t
The destination integer.
str
Type: Math.Gmp.Nativechar_ptr
The source integer.
base
Type: SystemInt32
The base.

Return Value

Type: Int32
If the string is a correct base base number, the function returns 0; if an error occurs it returns −1. rop is initialized even if an error occurs.
Remarks

See mpz_set_str for details.

Examples
// Create, initialize, and set the value of x.
mpz_t x = new mpz_t();
char_ptr value = new char_ptr("  1 234 567 890 876 543 211 234 567 890 987 654 321  ");
gmp_lib.mpz_init_set_str(x, value, 10);

// Assert the value of x.
char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", ""));

// Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
gmp_lib.free(s);
' Create, initialize, and set the value of x.
Dim x As New mpz_t()
Dim value As New char_ptr("  1 234 567 890 876 543 211 234 567 890 987 654 321  ")
gmp_lib.mpz_init_set_str(x, value, 10)

' Assert the value of x.
Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x)

Assert.IsTrue(s.ToString() = value.ToString().Replace(" ", ""))
' Release unmanaged memory allocated for x and string values.
gmp_lib.mpz_clear(x)
gmp_lib.free(value)
gmp_lib.free(s)

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