목차
1. 문제 정의
2. 문제 정의
3. 디자인
4. 결과
5. 소스 코드
2. 문제 정의
3. 디자인
4. 결과
5. 소스 코드
본문내용
1. 문제 정의
booth 알고리즘을 사용하여 곱셈한 것과 operator * 기호를 사용하여 곱셈한 것의 차이를 비교해 보는 프로그램의 작성
2. 문제 정의
Booth's algorithm 으로 곱하기 하는 function
long mult(const short multiplicand, const short multiplier);
을 작성하고, 곱하기 operator ('*')를 사용한 결과를 비교해 보기 위해
printf(...., mult(multiplicand, multiplier), multiplicand * multiplier);
와 같이 인쇄하는 프로그램을 작성하라.
단, multiplicand와 multiplier는 stdin 에서 반복해서 입력을 받는다.
short 타입의 비트 수는 다음과 같이 얻을 수 있다. (보통 n=16임)
n = sizeof(short) * 8
*************************** 10진수를 8bit의 2진수로 변환****************************
int binary(int n)
{
int i;
for(i=0x0080; i>=1; i>>=1)
{
if(n & i)
printf("1");
else
printf("0");
}
printf(" ");
return 0;
}
***************************** 10진수를 4bit의 2진수로 변환**************************
int binary1(int n)
{
int i;
for(i=0x0008; i>=1; i>>=1)
{
if(n & i)
printf("1");
else
printf("0");
}
printf(" ");
return 0;
}
****q의 마지막 비트 1이고 q_1의 마지막 비트가 0이면 a <- a-m,우측 1비트 쉬프트****
else if((aq&1)==1 && q_1==0)
{
temp = 0;
temp = temp | m;
temp = temp << 4;
aq = aq - temp;
.........
booth 알고리즘을 사용하여 곱셈한 것과 operator * 기호를 사용하여 곱셈한 것의 차이를 비교해 보는 프로그램의 작성
2. 문제 정의
Booth's algorithm 으로 곱하기 하는 function
long mult(const short multiplicand, const short multiplier);
을 작성하고, 곱하기 operator ('*')를 사용한 결과를 비교해 보기 위해
printf(...., mult(multiplicand, multiplier), multiplicand * multiplier);
와 같이 인쇄하는 프로그램을 작성하라.
단, multiplicand와 multiplier는 stdin 에서 반복해서 입력을 받는다.
short 타입의 비트 수는 다음과 같이 얻을 수 있다. (보통 n=16임)
n = sizeof(short) * 8
*************************** 10진수를 8bit의 2진수로 변환****************************
int binary(int n)
{
int i;
for(i=0x0080; i>=1; i>>=1)
{
if(n & i)
printf("1");
else
printf("0");
}
printf(" ");
return 0;
}
***************************** 10진수를 4bit의 2진수로 변환**************************
int binary1(int n)
{
int i;
for(i=0x0008; i>=1; i>>=1)
{
if(n & i)
printf("1");
else
printf("0");
}
printf(" ");
return 0;
}
****q의 마지막 비트 1이고 q_1의 마지막 비트가 0이면 a <- a-m,우측 1비트 쉬프트****
else if((aq&1)==1 && q_1==0)
{
temp = 0;
temp = temp | m;
temp = temp << 4;
aq = aq - temp;
.........
소개글