[Qt-interest] A way to test the number of digits after a decimal point?

Arnold Krille arnold at arnoldarts.de
Wed Apr 1 14:37:42 CEST 2009


On Wednesday 01 April 2009 14:06:13 Oliver.Knoll at comit.ch wrote:
> Arnold Krille wrote on Tuesday, March 31, 2009 8:38 PM:
> > 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)"
> ;)

Ah, so there should be a locale-aware number-strip...

> 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 ;)

Thats true for all but tax and bean-counters. :-)

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090401/d51711ae/attachment.bin 


More information about the Qt-interest-old mailing list