# 32 bit floating point multiplication

• 11-30-2004
32 bit floating point multiplication
Hi,

I am writing a program for multiplication of 32-floating point values. In order to find the significand, I will be dividing the initial number entered by the user by two, can you check if it is programmed correctly.

Code:

```        if (floatingnumber < 0) {sign[0]=1; floatingnumber *= -1;}  else {sign[0]=0;} //        printf ("\changing to positive bit %f\n", floatingnumber);         printf ("\nsign bit:        %i\n", sign[0]);         i=0;         while (floatingnumber !=0) {                 floatingnumber *= 0.5;                 tempnumber = (floatingnumber * 10);                 modulus = tempnumber%10;                 if (modulus > 0){temporaryarray[i] = 1;}                 else {temporaryarray[i] = 0;} //                printf ("\nnew digit = %i\n", temporaryarray[i]);                 floatingnumber -= (modulus/10); //                printf ("\nnew digit = %f\n", floatingnumber);                 i +=1;         }```

secondly, i will mutiply the two numbers entered by the user, can you please check if the shift and add algorithm is correct:

Code:

```void multiplysignificands (int mantissa1[24], int mantissa2[24]) { int finalmantissa[57], mantissa3[57]; int i=0, j=0, k=0; int shift=57, carry=0; for (i=0; i<=56; i++)  {finalmantissa[i] = 0; mantissa3[i] = 0;} printf ("\n"); for(i=0;i<=23;i++){printf("%i" ,mantissa1[i]);} printf ("\n"); for(i=0;i<=23;i++){printf("%i" ,mantissa2[i]);} printf ("\nmultiplying\n"); int zero=0; shift = 0; for(i=23;i>=0;i--) {                 for(int j=0;j<=23;j++)                         {        mantissa3[i+j] = (mantissa1[j] * mantissa2[i]);                         printf ("%i", mantissa3[i+j]);        }         printf("\nmultippy:  ");   k=0;         for (k=0; k<=56; k++)         {printf ("%i", mantissa3[k]);        }         printf ("\nafter adding array:");         carry=0;         for (k=56; k>=0; k--)         {                 if ((mantissa3[k] + finalmantissa[k] + carry) == 0)                         {finalmantissa[k] = 0; carry=0;}                 else if ((mantissa3[k] + finalmantissa[k] + carry) == 1)                         {finalmantissa[k] = 1; carry=0;}                 else if ((mantissa3[k] + finalmantissa[k] + carry) == 2)                         {finalmantissa[k] = 0 ; carry=1;}                 else if ((mantissa3[k] + finalmantissa[k] + carry) == 3)                         {finalmantissa[k] = 1  ; carry=1;}                 printf ("%i", finalmantissa[k]);         }         printf ("\n");         shift +=1;         zero +=1; } }```
Note: This is not the complete program.
• 11-30-2004
VirtualAce
Ill do some really fast wicked 32-bit multiplication for you.

Code:

``` float value1=100.0f; float value2=200.0f; float result=value1*value2;```