gmp_lib.mpn_lshift Method

GMP Native Interface for .NET

gmp_libmpn_lshift Method
Shift {sp, n} left by count bits, and write the result to {rp, n}.

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_limb_t mpn_lshift(
	mp_ptr rp,
	mp_ptr sp,
	mp_size_t n,
	uint count
)
Public Shared Function mpn_lshift ( 
	rp As mp_ptr,
	sp As mp_ptr,
	n As mp_size_t,
	count As UInteger
) As mp_limb_t
public:
static mp_limb_t mpn_lshift(
	mp_ptr^ rp, 
	mp_ptr^ sp, 
	mp_size_t n, 
	unsigned int count
)
static member mpn_lshift : 
        rp : mp_ptr * 
        sp : mp_ptr * 
        n : mp_size_t * 
        count : uint32 -> mp_limb_t 

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of sp.
count
Type: SystemUInt32
The number of bits ot shift.

Return Value

Type: mp_limb_t
The bits shifted out at the left are returned in the least significant count bits of the return value (the rest of the return value is zero).
Remarks

count must be in the range 1 to mp_bits_per_limb - 1. The regions {sp, n} and {rp, n} may overlap, provided rpsp.

This function is written in assembly for most CPUs.

Examples
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0xfffffffc, 0xffffffff });

// Set rp = sp << 1.
mp_limb_t bits = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1);

// Assert result of operation.
Assert.IsTrue(bits == 1);
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &HfffffffcUI, &HffffffffUI})

' Set rp = sp << 1.
Dim bits As mp_limb_t = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1)

' Assert result of operation.
Assert.IsTrue(bits = 1)
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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