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
)
Public Shared Function mpf_init_set_str (
rop As mpf_t,
str As char_ptr,
base As Integer
) As Integer
public:
static int mpf_init_set_str(
mpf_t^ rop,
char_ptr str,
int base
)
static member mpf_init_set_str :
rop : mpf_t *
str : char_ptr *
base : int -> int
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:
Int32This 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
gmp_lib.mpf_set_default_prec(64U);
char_ptr value = new char_ptr("234e-4");
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_str(x, value, 10);
Assert.IsTrue(x.ToString() == "0.234e-1");
gmp_lib.mpf_clear(x);
gmp_lib.free(value);
gmp_lib.mpf_set_default_prec(64UI)
Dim value As New char_ptr("234e-4")
Dim x As New mpf_t()
gmp_lib.mpf_init_set_str(x, value, 10)
Assert.IsTrue(x.ToString() = "0.234e-1")
gmp_lib.mpf_clear(x)
gmp_lib.free(value)
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