Click or drag to resize
gmp_libmpf_init_set_str Method
Initialize rop and set its value from the string in 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 mpf_init_set_str(
	mpf_t rop,
	char_ptr str,
	int base
)

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
str
Type: Math.Gmp.Nativechar_ptr
The operand string.
base
Type: SystemInt32
The base.

Return Value

Type: Int32
This function returns 0 if the entire string is a valid number in base base. Otherwise it returns -1.
Remarks

See mpf_set_str for details on the assignment operation.

Note that rop is initialized even if an error occurs. (I.e., you have to call mpf_clear for it.)

The precision of rop will be taken from the active default precision, as set by mpf_set_default_prec.

Examples
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number x to 0.0234.
char_ptr value = new char_ptr("234e-4");
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_str(x, value, 10);

// Assert that x is 40.
Assert.IsTrue(x.ToString() == "0.234e-1");

// Release unmanaged memory allocated for x and y.
gmp_lib.mpf_clear(x);
gmp_lib.free(value);
See Also