Click or drag to resize
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
)

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);
See Also