GMP Native Interface for .NET
gmp_libmpz_limbs_read Method |
Return a pointer to the limb array representing the absolute value of x.
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 mp_ptr mpz_limbs_read( mpz_t x )
Public Shared Function mpz_limbs_read ( x As mpz_t ) As mp_ptr
public: static mp_ptr^ mpz_limbs_read( mpz_t^ x )
static member mpz_limbs_read : x : mpz_t -> mp_ptr
Parameters
- x
- Type: Math.Gmp.Nativempz_t
The integer.
Return Value
Type: mp_ptrA pointer to the limb array representing the absolute value of x.
Remarks
The size of the array is mpz_size(x). Intended for read access only.
Examples
// Create and initialize new integer x. mpz_t x = new mpz_t(); gmp_lib.mpz_init(x); // Set the value of x. char_ptr value = new char_ptr("10000 00000000000000000000000000000000"); gmp_lib.mpz_set_str(x, value, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4); // Get pointer to the limbs of x. mp_ptr limbs = gmp_lib.mpz_limbs_read(x); // Assert the values of the limbs based on current architecture (x86 or x64). Assert.IsTrue(limbs[0] == 0); Assert.IsTrue(limbs[1] == (gmp_lib.mp_bytes_per_limb == 4 ? 16U : 256U)); // Release unmanaged memory allocated for x and value. gmp_lib.mpz_clear(x); gmp_lib.free(value);
' Create and initialize new integer x. Dim x As New mpz_t() gmp_lib.mpz_init(x) ' Set the value of x. Dim value As New char_ptr("10000 00000000000000000000000000000000") gmp_lib.mpz_set_str(x, value, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4)) ' Get pointer to the limbs of x. Dim limbs As mp_ptr = gmp_lib.mpz_limbs_read(x) ' Assert the values of the limbs based on current architecture (x86 or x64). Assert.IsTrue(limbs(0) = 0) Assert.IsTrue(limbs(1) = (If(gmp_lib.mp_bytes_per_limb = 4, 16UI, 256UI))) ' Release unmanaged memory allocated for x and value. gmp_lib.mpz_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