Working with a friend, I was trying to debug why log10(1/4) returns -inf, while log10(0.25) returns the proper answer of -0.60206.
I was using this program to test it, and tried moving the values to variables.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double t = 1/4;
double r = 0.25;
cout << log10(t) << endl;
cout << log10(r) << endl;
return 0;
}
That returned -inf and -0.60206.
Why would 1/4 not behave the same as 0.25?