Version: (using KDE 4.3.2) Compiler: GCC 4.3 OS: Linux Installed from: SuSE RPMs When calling KLocale::number() with a very high precision (I tried 100.000.000) will max out CPU and take forever. Same goes for QString::number(). Probably the best solution would a maximum value for precision. For example something like 200-300 since doubles can't have such a high precision. Qt version is 4.5.3
I assume you mean KLocale::formatNumber() 200-300 is way too big, too, "double" has a precision of about 16 digits... And "precision" is the number of fractional decimal digits, so it usually doesn't make sense to have more than 10 or so. If you are going to process numbers with higher precision than about 16 digits, then use libgmp or something similar.
(In reply to comment #1) > I assume you mean KLocale::formatNumber() > > 200-300 is way too big, too, "double" has a precision of about 16 digits... And > "precision" is the number of fractional decimal digits, so it usually doesn't > make sense to have more than 10 or so. > > If you are going to process numbers with higher precision than about 16 digits, > then use libgmp or something similar. The problem was I called it with such a high precision by mistake and it hung the whole program. I never wanted to have such an exact representation. I just thought it might keep other applications from hanging if an upper bound gets added.
Created attachment 41044 [details] Proposed patch
Looks good, will you backport to 4.4?
Christoph, it doesn't appear this was ever committed? Should we do this for formatMoney() as well? Should we be validating the input to setDecimalPlaces() and setMonetaryDecimalPlaces() as well? Cheers!
I asked for review on IRC some time ago, and for the specific function, it was proposed that Qt should make sure not to generate numbers with too many decimal digits in the first place. That's why I did not applied the patch, I also did not file a Qt bug, though. I do not know the other functions, so if they need some argument sanity checking, please go ahead.
Dear Bug Submitter, This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond. Thank you for helping us make KDE software even better for everyone!
Since KLocale is now only in kdelibs4support and the function in question only calls the Qt code I think we should report this as an upstream bug if it still applies. I don't have access to my dev environment right now to test but if I can see if it still happens with Qt5.12 and if so report it upstream.