Re: int/long anomaly in jython 2.7.0

"Niemann, Hartmut" <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <1AE3002F400CE4498072DFDF74A843CC20F48C16@DEFTHW99EH3MSX.ww902.siemens.net>
Hello Jeff,

thank you for confirming this behaviour and suggesting a workaround. Using long() works perfectly in my case.

Unfortunately i can not register at bugs.jython.org at the moment. At least it hasn't sent me the confirmation e-mail yet.

Mit freundlichen Grüßen
Dr. Hartmut Niemann


Von: Jeff Allen [mailto:[email protected]]
Gesendet: Donnerstag, 26. April 2018 08:58
An: [email protected]; Niemann, Hartmut (MO RS LM EN CCI SRD)
Betreff: Re: [Jython-dev] int/long anomaly in jython 2.7.0


Not AFAIK, thanks for finding it. It's still in the development tip:

>>> x = int(-(1<<31))

>>> y = x + 1

>>> x, y

(-2147483648, -2147483647)

>>> x.__format__('d') # Oops

'--2147483648'

>>> y.__format__('d')

'-2147483647'

Almost certainly there is some thinking error in int.__format__(), which % relies on, handling the positive of -2^31, which has no representation as an int. A work-around is to make it a long:

>>> '%d' % long(x)

'-2147483648'
The right place for this is http://bugs.jython.org/ . You could open an issue there (so you'll get e-mail when we work on it), or I will do so eventually.




Jeff Allen

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.