As the documentation states in Java's Float.toString(float) method, the float is represented with only as many digits that are needed to uniquely identify the value from adjacent float values. This behaviour isn't reflected in C#'s Single.ToString
method.
This means that in Java:
1500.45504 produces 1500.4551
2000.37408 produces 2000.374
whereas in C#:
1500.45504 produces 1500.455
2000.37408 produces 2000.374
Am I missing a flag or something in C# to replicate Java's behaviour? I can only use floating points, so using more precision, like a double, isn't feasible in this situation. Also, I can't use the G<num>
, or N<num>
specifiers, because the output would vary depending on whether or not the output needs a unique digit identifier.