Cryptography Reference
In-Depth Information
be shifted than there are digits the result is simply zero, almost as it is in real life.
The status value E_CLINT_UFL for underflow then merely indicates that there was
less to shift than was required, or, in other words, that the power of two by which
division was to be carried out was larger than the dividend, and so the quotient is
zero. The three functions are implemented in the following manner.
Function:
shift left (multiplication by 2)
int shl_l (CLINT a_l);
Syntax:
a_l (multiplicand)
Input:
Output:
a_l (product)
E_CLINT_OK if all is ok
E_CLINT_OFL if overflow
Return:
int
shl_l (CLINT a_l)
{
clint *ap_l, *msdptra_l;
ULONG carry = 0L;
int error = E_CLINT_OK;
RMLDZRS_L (a_l);
if (ld_l (a_l) >= (USHORT)CLINTMAXBIT)
{
SETDIGITS_L (a_l, CLINTMAXDIGIT);
error = E_CLINT_OFL;
}
msdptra_l = MSDPTR_L (a_l);
for (ap_l = LSDPTR_L (a_l); ap_l <= msdptra_l; ap_l++)
{
*ap_l = (USHORT)(carry = ((ULONG)*ap_l << 1) | (carry >> BITPERDGT));
}
if (carry >> BITPERDGT)
{
if (DIGITS_L (a_l) < CLINTMAXDIGIT)
{
*ap_l = 1;
SETDIGITS_L (a_l, DIGITS_L (a_l) + 1);
error = E_CLINT_OK;
}
 
Search WWH ::




Custom Search