[PyQt] QLocale.toString() with great numbers.
Vincent Vande Vyvre
vincent.vande.vyvre at telenet.be
Tue Aug 23 11:31:49 BST 2016
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?
Regards.
Vincent
More information about the PyQt
mailing list