Преобразование десятичной дроби в восьмеричную дробь C++
Целое число могу перевести в восьмеричную а вот с дробью проблемы

#include
#include
#include
#include
using namespace std;
int main()
{
float num;
double rem = 0;
int dec = 0;
int i = 0;
int k=0;

cout << "Please enter a number with a decimal point: ";
cin >> num;
float ohalf = num - (int)num;
int half = num;
while (half !=0)
{
rem = half % 10;
half /= 10;
dec += rem *= pow(8, i);
i++;
}
cout< i = -1;
while (ohalf != 0)
{
rem = ohalf *pow(8, i);
i--;
}
cout << rem;


return 0;
}
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.