Can anyone tell me why I am getting different values of lhs and rhs? I expected them to produce similar results.
double lhs=y*log10(x); double rhs=x*log10(y);
**
double lhs=log10(x); double rhs=log10(y); lhs*=y; rhs*=x;
I am getting wrong answers for x=6,y=6 while submitting on codeforces but I am getting correct on VSCode.
How are you doing comparison directly like this? Never do comparisons without some tolerance in precision. There might be a precision error as small as $$$10^{-15}$$$ or even smaller which makes both not equal to each other. You can do something like:
You are lucky that the other code passed with direct comparisons.
A known example: 0.1 + 0.1 + 0.1 != 0.3
thank you so much