Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 4th, 2010 | Syntax: C++ | Size: 0.62 KB | Hits: 68 | Expires: Never
Copy text to clipboard
  1. void mult_unit(string fp1, string fp2)
  2. {
  3.         double exp1=-1, exp2=-1;
  4.         long double temp1=0, temp2=0, temp3=0;
  5.  
  6.         for(int a=0; a<23; a++)
  7.         {
  8.                 if(fp1[a]=='1')
  9.                         temp1 += pow(2, exp1);
  10.                 exp1--;
  11.         }
  12.  
  13.         cout << "temp1 = " << temp1 << endl;
  14.  
  15.         for(int a=0; a<23; a++)
  16.         {
  17.                 if(fp2[a]=='1')
  18.                         temp2 += pow(2, exp2);
  19.                 exp2--;
  20.         }
  21.  
  22.         cout << "temp2 = " << temp2 << endl;
  23.  
  24.         temp3 = temp1 * temp2;
  25.  
  26.         cout << "temp3 = " << temp3 << endl;
  27. }