String::getDoubleValue returning too much precision


#1

Hey folks, I’m not sure if this is a specifically Windows-related problem, but when I have a String which is, let’s say “.1”, and then I call getDoubleValue, I get 0.10000000000000001. Anyone else having this issue?

Mainly I’m just concerned because, when I convert back to a String, it’s hard to fit into small text boxes, etc., because it’s so long. I’m aware that I can say String(doubleVal, numDecimalPlaces), but I’d prefer not to have it display any trailing zeros, no matter what the value is.

Any help appreciated!


#2

0.1 has no exact representation in a double


#3

Hmm… ok I figured it was something like that. For now then I’m just gonna have to do some truncation logic I guess.