Klaus Niederkrueger kniederk at math.uni-koeln.de
Mon May 2 12:22:11 BST 2005

Reading the documentation of "formatNumber", I started to wonder about

Why is

KLocale::formatNumber ( const QString & numStr )

deprecated? If we change its implementation, it would really make sense to
keep it (because the QString could hold arbitrarily large numbers).
Somehow I think the way it has been coded is strange:  The above function
just calls

return formatNumber(numStr.toDouble());

where in "formatNumber(double num, int prec)", the double is converted
back to a string (and as a side-effect the QString you pass to
formatNumber can only be as large as a double).

I would like to make the following changes, but I don't know if they are
o.k. with you?

I would like to use "formatNumber(QString)" as the main method, and have
"formatNumber(double)" just as a wrapper for convenience.

The main reason is that I am maintaining the calculator, and kcalc
contains more or less a reimplementation of "formatNumber". The problem is
that kcalc uses "long long double" to handle numbers internally, which
does not work correctly with "Klocale". By having "formatNumber(QString)"
working on arbitrarily long QStrings, I could delete a part of the

My first question is: Is it o.k. if I change this?

If yes, my second question: "formatNumber(double, int)" has two arguments,
whereas "formatNumber(QString)" only has one. If I change the second
function to "formatNumber(QString num, int prec = -1)" is this still
binary compatible with the old code?



More information about the kde-core-devel mailing list