GMP Native Interface for .NET
gmp_libmpz_inp_raw Method |
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 mpz_inp_raw( mpz_t rop, ptr<FILE> stream )
Public Shared Function mpz_inp_raw ( rop As mpz_t, stream As ptr(Of FILE) ) As size_t
public: static size_t mpz_inp_raw( mpz_t^ rop, ptr<FILE>^ stream )
static member mpz_inp_raw : rop : mpz_t * stream : ptr<FILE> -> size_t
Parameters
- rop
- Type: Math.Gmp.Nativempz_t
The result operand. - stream
- Type: Math.Gmp.NativeptrFILE
Pointer to file stream.
Return Value
Type: size_tReturn the number of bytes read, or if an error occurred, return 0.
Remarks
This routine can read the output from mpz_out_raw also from GMP 1, in spite of changes necessary for compatibility between 32-bit and 64-bit machines.
Examples
// Create, initialize, and set the value of op to 123456. mpz_t op = new mpz_t(); gmp_lib.mpz_init_set_ui(op, 123456U); // Write op to a temporary file. string pathname = System.IO.Path.GetTempFileName(); ptr<FILE> stream = new ptr<FILE>(); _wfopen_s(out stream.Value.Value, pathname, "w"); Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7); fclose(stream.Value.Value); // Read op from the temporary file, and assert that the number of bytes read is 6. _wfopen_s(out stream.Value.Value, pathname, "r"); Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) == 7); fclose(stream.Value.Value); // Assert that op is 123456. Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U); // Delete temporary file. System.IO.File.Delete(pathname); // Release unmanaged memory allocated for op. gmp_lib.mpz_clear(op);
' Create, initialize, and set the value of op to 123456. Dim op As New mpz_t() gmp_lib.mpz_init_set_ui(op, 123456UI) ' Write op to a temporary file. Dim pathname As String = System.IO.Path.GetTempFileName() Dim stream As New ptr(Of FILE)() _wfopen_s(stream.Value.Value, pathname, "w") Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) = 7) fclose(stream.Value.Value) ' Read op from the temporary file, and assert that the number of bytes read is 6. _wfopen_s(stream.Value.Value, pathname, "r") Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) = 7) fclose(stream.Value.Value) ' Assert that op is 123456. Assert.IsTrue(gmp_lib.mpz_get_ui(op) = 123456UI) ' Delete temporary file. System.IO.File.Delete(pathname) ' Release unmanaged memory allocated for op. gmp_lib.mpz_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.
See Also