There are only 3/4 AC in java which uses BigDecimal. Is there is any difference in standard atan2 function in Java & c++ ? if yes, is there any other way to handle precision without using BigDecimal.
That’s odd… the AC code above gives WA when I run it: nXndu1
However all other accepted C++ solutions I found differ from your Java solution in that they use long double and not double. The difference is not in the library functions but in the datatypes used. long double has better precision and that’s probably the reason it gets AC. Since there is no long double type in Java, I suppose BigDecimal is the only way out.
No it’s not. If you see the Wikipedia link I have provided it says
As with C’s other floating-point types, it may not necessarily map to an IEEE format.
And also
With the GNU C Compiler, long double is 80-bit extended precision on x86 processors regardless of the physical storage used for the type (which can be either 96 or 128 bits).
So long double uses 80 bits whereas double uses 64 bits.