Hi
my python 2.3.4 for windows refuse to execute line float("NaN"). It
says: float("NaN")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for float(): NaN
The same line works as expected on Linux and Solaris with python 2.3.4.
Could anybody explain what is possibly wrong here? is it bug or
feature?
Andrei 6 2662
[as************* ***@yahoo.com] my python 2.3.4 for windows refuse to execute line float("NaN"). It says:
float("NaN")
Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: invalid literal for float(): NaN
The same line works as expected on Linux and Solaris with python 2.3.4. Could anybody explain what is possibly wrong here? is it bug or feature?
Neither -- all Python behavior in the presence of float NaNs,
infinities, or signed zeroes is a platform-dependent accident. In
this specific case, the accident is that the platform C runtime
string->double functions on your Linux and Solaris boxes recognize
"NaN", but Microsoft's string->double functions do not. Microsoft's
libraries can't even read back the strings they *produce* for
NaNs.(usually "-1.#IND").
<as************ ****@yahoo.com> wrote: my python 2.3.4 for windows refuse to execute line float("NaN"). It says:
float("NaN")
Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: invalid literal for float(): NaN
The same line works as expected on Linux and Solaris with python 2.3.4. Could anybody explain what is possibly wrong here? is it bug or feature?
feature, sort of. see http://www.python.org/peps/pep-0754.html :
"Currently, the handling of IEEE 754 special values in Python
depends on the underlying C library. Unfortunately, there is little
consistency between C libraries in how or whether these values
are handled. For instance, on some systems "float('Inf ')" will
properly return the IEEE 754 constant for positive infinity. On
many systems, however, this expression will instead generate
an error message."
the PEP includes a pointer to a module that lets you replace that "float"
with the fully portable:
import fpconst
def myfloat(x):
if x == "NaN":
return fpconst.NaN
return float(x)
</F> as************* ***@yahoo.com wrote: my python 2.3.4 for windows refuse to execute line float("NaN"). It says:
float("NaN" )
Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: invalid literal for float(): NaN
The same line works as expected on Linux and Solaris with python 2.3.4. Could anybody explain what is possibly wrong here? is it bug or feature?
Differences in the underlying platform/C library. No difference
here with similar platforms.
-Peter
Tim Peters wrote: Neither -- all Python behavior in the presence of float NaNs,
infinities, or signed zeroes is a platform-dependent accident.
C99 and Fortran 2003 have IEEE arithmetic. If CPython could be compiled
with a C99 compiler, would it also have IEEE arithmetic? Do Python
number-crunchers think this is important?
[be*******@aol.c om] C99 and Fortran 2003 have IEEE arithmetic.
Not that simple (e.g., C99 doesn't *require* it; but it has a pile of
specified IEEE behaviors a conforming C99 compiler can choose to
support (or not), along with a preprocessor symbol those that do so
choose can #define to advertise that decision).
If CPython could be compiled with a C99 compiler, would it also have IEEE arithmetic?
Fully define "have IEEE arithmetic". Not that simple either. Even on
Windows using Microsoft's C89 compiler, Python's float + - * and /
meet the 754 standard provided you're running on a Pentium or AMD
chip. The IEEE standard says nothing about how a 754-conforming
implementation has to spell infinities or NaNs in string<->float
conversions, so that MS produces -1.#IND for a NaN doesn't oppose the
754 standard.
Do Python number-crunchers think this is important?
Some do, some don't. The only contributors motivated enough to "do
something about it" gave us Python's fpectl module, which is aimed
mostly at making it look like 754 gimmicks don't exist (fiddling the C
runtime system so that operations that try to produce a NaN or
infinity from finite operands raise exceptions instead).
<as************ ****@yahoo.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. . Hi
my python 2.3.4 for windows refuse to execute line float("NaN"). It says:
float("NaN") Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: invalid literal for float(): NaN
The same line works as expected on Linux and Solaris with python 2.3.4. Could anybody explain what is possibly wrong here? is it bug or feature?
Andrei
As others have gently tiptoed around, it's basically
the lack of a group of enthusiastic and dedicated
volunteers to make it happen.
Nobody is really happy with the current situation,
but Python is a volunteer effort, and the current
set of volunteers isn't really motivated to put in
a very large amount of work on something that
they think would have relatively little benefit.
In other words, if someone wants to dig in and
do the work, I'm sure the core developers will
look at it favorably - as long as it meets the
usual standards for core development, including
documentation and maintainability .
The bar is lower than it has ever been, by the
way. It used to be: It has to work the same way
on all supported platforms. Now it's just: it has
to work the same on the core platforms, and
if anyone else really wants to work on the others,
more power to them.
John Roth This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Boštjan Jerko |
last post by:
Hello !
I need to know if the result of math formula is nan (Not a number).
How can I do that?
Thanks,
B.
|
by: geskerrett |
last post by:
We are working on a project to decipher a record structure of an old
accounting system that originates from the late80's mid-90's.
We have come across a number format that appears to be a "float" but
doesn't match any of the more standard implementations.
so we are hoping this is a recognizable number storage format with an
identifiable name AND pre-built conversion method
similiar to the "struct" modules available in python.
Here is...
|
by: Pierre Quentel |
last post by:
Hi all,
In some program I was testing if a variable was a boolean, with this
test : if v in
My script didn't work in some cases and I eventually found that for v =
0 the test returned True
So I changed my test for the obvious "if type(v) is bool", but I still
find it confusing that "0 in " returns True
|
by: tkpmep |
last post by:
I write data to Excel files using PyExcelerator 0.6.3.a and have done
so successfully for small files (10-15 cells). I'm experiencing an
error when writing a big chunk of data (10,000 cells) to Excel. By way
of comparison, the same data writes perfectly well to a csv file using
Python's built in csv module. I run the program in PyScripter, and the
traceback shows the following sequence of calls:
main (my routine)...
|
by: Peter Knörrich |
last post by:
Hello,
I've found another inconsistency, and looking through the
list archives I can find mentions of funky stuff like
print float('inf')
giving
Infanity
| |
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 393 open (+15) / 3315 closed (+17) / 3708 total (+32)
Bugs : 908 open (+22) / 5975 closed (+49) / 6883 total (+71)
RFE : 223 open ( -1) / 229 closed ( +2) / 452 total ( +1)
New / Reopened Patches
______________________
|
by: Peter Hansen |
last post by:
I'm investigating a puzzling problem involving an attempt to generate a
constant containing an (IEEE 754) "infinity" value. (I understand that
special float values are a "platform-dependent accident" etc...)
The issue appears possibly to point to a bug in the Python compiler,
with it producing inconsistent results. I'm using "Python 2.4.2 (#67,
Sep 28 2005, 12:41:11) on win32".
This code sometimes produces a float of 1.0, sometimes...
|
by: daniel |
last post by:
I'm so confused by the keyword "is" and "==" equal sign, it seems they
could be exchanged in some contexts, but not in others, what's the
difference between them in terms of comparation?
thanks...
daniel
|
by: Catalyst159 |
last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows:
Part A: Maximum FAR and Floor Area:
Part B: Gross Floor Area of the main floors of the main house:
Part C: Gross Floor Area of the basement or cellar:
Part D: Gross Floor Area of the attic:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
| |