Peculiar boundary cases: 2.0**31-1.0
2147483647.0 int(2147483647.0)
2147483647L int(2147483647L )
2147483647 -2.0**31
-2147483648.0 int(-2147483648.0)
-2147483648L int(-2147483648L )
-2147483648
some kind of one-off error? I.e., just inside extremes works:
[int(x) for x in (-2.0**31, -2.0**31+1.0, 2.0**31-2.0, 2.0**31-1.0)]
[-2147483648L, -2147483647, 2147483646, 2147483647L]
But those longs at the extremes can be converted successfully, so int(int(x)) works ;-/
[int(int(x)) for x in (-2.0**31, -2.0**31+1.0, 2.0**31-2.0, 2.0**31-1.0)]
[-2147483648, -2147483647, 2147483646, 2147483647]
ISTM this is a buglet, or at least a wartlet for a 32-bit system ;-)
Almost forgot:
Python 2.4b1 (#56, Nov 3 2004, 01:47:27)
[GCC 3.2.3 (mingw special 20030504-1)] on win32
but same thing on 2.3.2:
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information. [int(x) for x in (-2.0**31, -2.0**31+1.0, 2.0**31-2.0, 2.0**31-1.0)]
[-2147483648L, -2147483647, 2147483646, 2147483647L] [int(int(x)) for x in (-2.0**31, -2.0**31+1.0, 2.0**31-2.0, 2.0**31-1.0)]
[-2147483648, -2147483647, 2147483646, 2147483647]
Hm, ... except for the thought that CPUs with 64-bit integers might truncate maxint
when converting to float, I might say maybe these reprs should be tested
for equality in the system tests?
import sys repr(int(float(sys.maxint))), repr(sys.maxint)
('2147483647L', '2147483647') repr(int(float(-sys.maxint-1))), repr(-sys.maxint-1)
('-2147483648L', '-2147483648')
or maybe at least check for equality of these?:
type(int(float(sys.maxint))), type(sys.maxint)
(<type 'long'>, <type 'int'>) type(int(float(-sys.maxint-1))), type(-sys.maxint-1)
(<type 'long'>, <type 'int'>)
Regards,
Bengt Richter 0 1298 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Helmut Jarausch |
last post by:
Hi,
I'm not sure if this is the right place to report on buglets in the CVS
version of Python.
Anyway
In file dist/src/Objects/floatobject.c line 393
it most probably must read...
|
by: Grant Edwards |
last post by:
I'm getting tired of seeing meaningless warnings from my code,
but I can't figure out how to get rid of them:
For example:
fcntl.ioctl(fd,0xc0047a80,s) causes
FutureWarning: hex/oct...
|
by: Bengt Richter |
last post by:
Peculiar boundary cases:
>>> 2.0**31-1.0
2147483647.0
>>> int(2147483647.0)
2147483647L
>>> int(2147483647L )
2147483647
>>>
>>> -2.0**31
|
by: Nick Coghlan |
last post by:
<Sorry for the disconnected reply -I've been having news server issues, and just
switched to the mailing list instead>
A quick check of the source code reveals that this behaviour is deliberate....
|
by: Dave Huang |
last post by:
Hi, I don't actually know Python; I'm just trying to debug a problem
I encounted in another program, so apologies if this has been
covered before. I did do some Google searches though, and didn't...
|
by: Marc Ferry |
last post by:
I already posted this mail in comp.sys.hp and comp.sys.hp.hpux but had
no response. As this problem might be present on other OSes than HP-UX
10.20, I crosspost it here, in the hope of getting an...
|
by: Frank Millman |
last post by:
Hi all
I am using win32 odbc to connect to SQL Server. I have just started
using the 'bit' data type, which is a boolean type which can store 1 or
0.
This works with win32, but it returns '1'...
|
by: bearophileHUGS |
last post by:
In some algorithms a sentinel value may be useful, so for Python 3.x
sys.maxint may be replaced by an improvement of the following infinite
and neginfinite singleton objects:
class...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |