[PyQt] QLocale.toString() with great numbers.
Phil Thompson
phil at riverbankcomputing.com
Tue Aug 23 18:20:49 BST 2016
On 23 Aug 2016, at 11:31 am, Vincent Vande Vyvre <vincent.vande.vyvre at telenet.be> wrote:
>
> Hi,
>
> I want to display a number with the locale conventions, then I use QLocale.toString for that but with some great numbers I get strange results.
>
> Python 3.4.3 (default, Oct 14 2015, 20:28:29)
> [GCC 4.8.4] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt5.QtCore import QLocale
> >>> loc = QLocale.system().name()
> >>> lang = QLocale(loc)
> >>> lang.toString(1000000000)
> '1.000.000.000'
> >>> lang.toString(2000000000)
> '2.000.000.000'
> >>> lang.toString(5315035136)
> '1.020.067.840'
>
> Same with PyQt4
>
> Python 2.7.6 (default, Jun 22 2015, 17:58:13)
> [GCC 4.8.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt4.QtCore import QLocale
> >>> lang = QLocale(QLocale.system().name())
> >>> lang.toString(2100000000)
> PyQt4.QtCore.QString(u'2.100.000.000')
> >>> lang.toString(2315035136)
> PyQt4.QtCore.QString(u'-1.979.932.160')
> >>> lang.toString(5315035136)
> PyQt4.QtCore.QString(u'1.020.067.840')
>
>
> This behaviour appears for the values up to 2,100,000,000.
> Theses examples are on a 64 bits machine, on a 32 bits the return for great value is always -1.
>
> Is it a question of int versus long number?
Should be fixed in tonight's snapshot. I don't plan to change PyQt4.
Thanks,
Phil
More information about the PyQt
mailing list