Why do the following not equal each other?
0.37024025
and
(sqrt(2)*M_PI/3)*(1/4)
I see significant divergence in my solution, but all I did was place a number with the formula behind it.
Why do the following not equal each other?
0.37024025
and
(sqrt(2)*M_PI/3)*(1/4)
I see significant divergence in my solution, but all I did was place a number with the formula behind it.
 
    
    The expression (sqrt(2)*M_PI/3)*(1/4) has integer division. Namely, (1/4) is always going to be zero, making the entire expression zero since it's multiplied by that.
(sqrt(2.0)*M_PI/3.0)*(1.0/4.0);
Is a little bit closer to what you wanted, but when comparing doubles exactly I'd use an epsilon threshold and test if both are "close enough" to each other based on that:
bool cmp(double d1, double d2, double epsilon)
{
    return std::fabs(d1 - d2) < epsilon;
}
 
    
    You're performing integral division with 1/4 which will result in 0, not 0.25. Try adding a .0f or .0 suffix for float or double, respectively.
