Advertisement
mercMatvey4

Untitled

Dec 12th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. /*int main()
  2. {
  3.     setlocale(LC_ALL,"");
  4.     string num,integer_temp,fraction_temp;
  5.     int value,integer;
  6.     double fraction,result;
  7.     system("cls");
  8.     cout << "Введите число, дробная часть указывается через \" . \"\n\n";
  9.     cin >> num;
  10.     value = num.find('.');
  11.     integer_temp = num.substr(0, value);
  12.     fraction_temp = num.substr(value+1, num.size());
  13.     fraction_temp.insert(0,"0");
  14.     integer = stoi(integer_temp);
  15.     fraction = stod(fraction_temp)/powerup(10,fraction_temp.size()-1);
  16.     int int_res = 0,temp = 1; // temp - разряды
  17.     while (integer)
  18.     {
  19.         int_res += integer % 8 * temp;
  20.         integer /= 8;
  21.         temp *= 10;
  22.     }*/
  23.     double frac_res = 0, temp1; // frac_res результат перевода, temp1 - переменная для разрядов
  24.     for (int i = 0; i < 8; i++)
  25.     {
  26.         fraction *= 8;
  27.         double temp1 = (int)fraction;
  28.         frac_res += temp1 * powerdown(10,i+1);
  29.         fraction -= temp1;
  30.     }
  31.     /*result = int_res + frac_res;
  32.     cout << setprecision(8+value) << result ;
  33. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement