Ok, so I did some debugging and now know what the problem is. My DecimalFormat.format() method for some reason changes things like “2.5” to “2,5”!
That’s why, if result is, for example, 2.5 (as opposed to 3,33333… and such), my statement
String.valueOf(result).equals(df.format(result))
is false, not true, as I intended
Here’s how I imported the class
import java.text.DecimalFormat;
Here’s how I created a DecimalFormat object
private static final DecimalFormat df = new DecimalFormat("#.##");
Why would the method do such a weird thing and how do I fix it?
In case you need the entire code, it’s here (it’s too big to paste here, I think)