[Qt-interest] A way to test the number of digits after a decimal point?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Wed Apr 1 14:06:13 CEST 2009
Arnold Krille wrote on Tuesday, March 31, 2009 8:38 PM:
> ...
> "after the decimal _point_" Please remember that not all countries
> use the point for decimals. :-)
That's true :)
> If the string is already (local
> aware) validated to be a float number, the right thing is to strip
> all white spaces (yes, there are countries that use white space as
> thousands separator) and look whether there is a character in there
> that is not a digit. [...] and the count of chars (which would then
> be digits) after the non-digit is the number of digits after the
> decimal separator.
While the idea behind that is certainly correct, the description of the algorithm is not in every case: While there might certainly be countries that separate the 1000s with whitespace, there are others which separate them with ' (single quote, i.e. a NON-digit character ;), as in:
"Swiss tax payers spent CHF 68'000'000'000 of their valuable money to Save The Banks(tm)"
;)
Cheers, Oliver
p.s. Note: bankers tend to automatically blend out the last few digits of a number, as soon as it becomes at least 6 digits long (it is only the first two numbers that really count in that case, so e.g. 68'000'000'000 and 68'500'000'000 are basically the same). Numbers below that are ignored anyway, and in that context no one gives a damn about the fractional part either ;)
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list