gmp_libmpf_inp_str Method |
Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
public static size_t mpf_inp_str( mpf_t rop, ptr<FILE> stream, int base )
Public Shared Function mpf_inp_str ( rop As mpf_t, stream As ptr(Of FILE), base As Integer ) As size_t
public: static size_t mpf_inp_str( mpf_t^ rop, ptr<FILE>^ stream, int base )
static member mpf_inp_str : rop : mpf_t * stream : ptr<FILE> * base : int -> size_t
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_tReturn the number of bytes read, or if an error occurred, return 0.
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.
// 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);
' Create and initialize op. Dim op As New mpf_t() gmp_lib.mpf_init(op) ' Write op to a temporary file. Dim pathname As String = 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. Dim stream As New ptr(Of FILE)() _wfopen_s(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) = 123456UI) ' Delete temporary file. System.IO.File.Delete(pathname) ' Release unmanaged memory allocated for op. gmp_lib.mpf_clear(op)
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.