a[4] | a[3] | a[2] | a[1] | a[0] | |
<<왼쪽으로 2만큼 시프트<< |
|||||
a[3] | a[2] | a[1] | a[0] | 0 | 0 |
1 2 3 4 5 6 7 8 9 10 11 12 |
void bigint_shru4(bigint *dest, u4 src) { u4 shiftb=src>>5; src=src&31; dest->dats[0]=dest->dats[shiftb]>>src; for (u4 i=1;i<dest->len-shiftb;++i) { dest->dats[i-1]|=dest->dats[i+shiftb]<<(32-src); dest->dats[i]=dest->dats[i+shiftb]>>src; } memset (dest->dats-shiftb, 0, shiftb* sizeof (u4)); } |
1 2 3 4 5 6 7 8 9 10 11 12 |
void bigint_shlu4(bigint *dest, u4 src) { u4 shiftb=src>>5; src=src&31; dest->dats[dest->len-1]=dest->dats[dest->len-shiftb-1]<<src; for (u4 i=dest->len-2;( long )i>=( long )shiftb;--i) { dest->dats[i+1]|=dest->dats[i-shiftb]>>(32-src); dest->dats[i]=dest->dats[i-shiftb]<<src; } memset (dest->dats, 0, shiftb* sizeof (u4)); } |
BigInteger를 구현해보자 - 8. 10진수로 출력하기(알고리즘) (3) | 2009.04.26 |
---|---|
BigInteger를 구현해보자 - 7. 나누기 (2) | 2009.04.25 |
BigInteger를 구현해보자 - 6. 크기비교 (4) | 2009.04.21 |
BigInteger를 구현해보자 - 4. 곱셈과 부호 체크 (0) | 2009.03.29 |
BigInteger를 구현해보자 - 3. 음수의 표현, 뺄셈 (4) | 2009.03.29 |
BigInteger를 구현해보자 - 2. 정의와 생성, 파괴, 덧셈 (8) | 2009.03.29 |
댓글 영역