Java DecimalFormat returns a "?"
It's not a question mark, it's a U+FFFD REPLACEMENT CHARACTER
, which is displayed as ? since it can't be mapped to the output encoding:
NaN is formatted as a string, which typically has a single character \uFFFD. This string is determined by the DecimalFormatSymbols object. This is the only value for which the prefixes and suffixes are not used.
Similarly, ? in representation of infinity is a U+221E INFINITY
character (∞).
Infinity is formatted as a string, which typically has a single character \u221E, with the positive or negative prefixes and suffixes applied. The infinity string is determined by the DecimalFormatSymbols object.
See also:
DecimalFormat
javadoc
It'll return "?" if X
is Float.NaN
or Float.POSITIVE_INFINITY
. It appears that Float.NEGATIVE_INFINITY
returns "-?".