How can I restrict the value of a floating point number to only have two significant digits after the decimal point?

John Mitchell

Well, you could convert the floating point value to a string and then parse the string and trim it at the desired digits (and you could implement whatever rounding method you like in the process). That's pretty heinous.

If the floating point value is small enough, you could scale the value by e.g., 100, then use the java.lang.Math.round() method, and finally, divide the number by 100 to get back to the original scale.