Currently, I'm working on a project in C++. I am calculating quotients of Log and I know the rest of the quotients contain decimals. However, when it is printed in the console, it comes up as a whole number. How can I display an accurate number of a further quotient instead of the whole number?
#include <iostream>
#include <math.h>
using namespace std;
int BinaryLog(int);
int BinaryLog2(int);
int main() {
int number = 0;
int answer = 0;
//prompting user for an integer
cout << "Please enter a positive integer ";
cin >> number;
answer = BinaryLog(number);
answer = BinaryLog(number);
// calling function
cout << "The binary logarithim of " << number
<< " is " << answer << endl;
****cout << "Other binary logs of this number " << number
<< " are " << answer << endl;
// closing scope
cout << number / 2 << endl;
cout << number / 2 / 2 << endl;
cout << number / 2 / 2 / 2 << endl;
cout << number / 2 / 2 / 2 / 2 << endl;
return 0;****
**^^^^^^^^^ Calculation for further quotients here ^^^^^^**
}
int BinaryLog(int num) {
int count = 0;
double quotient = num;
while (quotient >= 2)
{
count++;
quotient = quotient / 2;
}
return count;
}
int BinaryLog2(int num) {
int count = 0;
double quotient = num;
while (quotient >= 6)
{
count++;
quotient = quotient / 6;
}
return count;
}