|
From: Jeff A. <ja...@fa...> - 2018-04-26 06:57:56
|
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
On 25/04/2018 08:05, Niemann, Hartmut wrote:
>
> Hello!
>
> Is this a known bug in Jython 2.7.0?
>
> x = int(-(1<<31))
>
> print ('%d' % x)
>
> results in
>
> --2147483648
>
> With two ‘-‘ signs.
>
> For -(1<<31)+1 everything is fine,
>
> for -(1<<31)-1 the resulting x has type long and everything is fine as
> well.
>
> convert x to long and the result is correct as well.
>
> Mit freundlichen Grüßen
> Dr. Hartmut Niemann
>
> Siemens AG
> Mobility Division
> Rolling Stock
> Standardization, Remote Control, Display
> MO RS LM EN CCI SRD
> Werner-von-Siemens-Str. 67
> 91052 Erlangen, Deutschland
> Mobil: +49 173 5342327
> mailto:har...@si...
> www.siemens.com/ingenuityforlife <https://siemens.com/ingenuityforlife>
> www.siemens.com/ingenuityforlife
> Siemens Aktiengesellschaft: Vorsitzender des Aufsichtsrats: Jim
> Hagemann Snabe; Vorstand: Joe Kaeser, Vorsitzender; Roland Busch, Lisa
> Davis, Klaus Helmrich, Janina Kugel, Cedrik Neike, Michael Sen, Ralf
> P. Thomas; Sitz der Gesellschaft: Berlin und München, Deutschland;
> Registergericht: Berlin Charlottenburg, HRB 12300, München, HRB 6684;
> WEEE-Reg.-Nr. DE 23691322
>
>
>
> ------------------------------------------------------------------------------
> 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
> Jyt...@li...
> https://lists.sourceforge.net/lists/listinfo/jython-dev
|