Click or drag to resize
gmp_libmpf_inp_str Method
Read a string in base base from stream, and put the read float in rop.

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 size_t mpf_inp_str(
	mpf_t rop,
	ptr<FILE> stream,
	int base
)

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
stream
Type: Math.Gmp.NativeptrFILE
Pointer to file stream.
base
Type: SystemInt32
The base.

Return Value

Type: size_t
Return the number of bytes read, or if an error occurred, return 0.
Remarks

The string is of the form "M@N" or, if the base is 10 or less, alternatively "MeN". "M" is the mantissa and "N’" is the exponent. The mantissa is always in the specified base. The exponent is either in the specified base or, if base is negative, in decimal. The decimal point expected is taken from the current locale, on systems providing localeconv.

The argument base may be in the ranges 2 to 36, or -36 to -2. Negative values are used to specify that the exponent is in decimal.

Unlike the corresponding mpz function, the base will not be determined from the leading characters of the string if base is 0. This is so that numbers like "0.23" are not interpreted as octal.

Examples
// Create and initialize op.
mpf_t op = new mpf_t();
gmp_lib.mpf_init(op);

// Write op to a temporary file.
string pathname = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllText(pathname, "0.123456e6");

// Read op from the temporary file, and assert that the number of bytes read is 6.
ptr<FILE> stream = new ptr<FILE>();
_wfopen_s(out stream.Value.Value, pathname, "r");
Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) == 10);
fclose(stream.Value.Value);

// Assert that op is 123456.
Assert.IsTrue(gmp_lib.mpf_get_ui(op) == 123456U);

// Delete temporary file.
System.IO.File.Delete(pathname);

// Release unmanaged memory allocated for op.
gmp_lib.mpf_clear(op);
See Also