473,727 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PPC floating equality vs. byte compilation

I ran into a phenomenon that seemed odd to me, while testing a
build of Python 2.4.1 on BeOS 5.04, on PowerPC 603e.

test_builtin.py , for example, fails a couple of tests with errors
claiming that apparently identical floating point values aren't equal.
But it only does that when imported, and only when the .pyc file
already exists. Not if I execute it directly (python test_builtin.py ),
or if I delete the .pyc file before importing it and running test_main().

For now, I'm going to just write this off as a flaky build. I would
be surprised if 5 people in the world care, and I'm certainly not one
of them. I just thought someone might find it interesting.

The stalwart few who still use BeOS are mostly using Intel x86 hardware,
as far as I know, but the first releases were for PowerPC, at first
on their own hardware and then for PPC Macs until Apple got nervous
and shut them out of the hardware internals. They use a Metrowerks
PPC compiler that of course hasn't seen much development in the last
6 years, probably a lot longer.

Donn Cave, do**@drizzle.co m
Jul 21 '05 #1
4 1252
Donn Cave wrote:
I ran into a phenomenon that seemed odd to me, while testing a
build of Python 2.4.1 on BeOS 5.04, on PowerPC 603e.

test_builtin.py , for example, fails a couple of tests with errors
claiming that apparently identical floating point values aren't equal.
But it only does that when imported, and only when the .pyc file
already exists. Not if I execute it directly (python test_builtin.py ),
or if I delete the .pyc file before importing it and running test_main().

For now, I'm going to just write this off as a flaky build. I would
be surprised if 5 people in the world care, and I'm certainly not one
of them. I just thought someone might find it interesting.


I have a faint recollection of seeing other references to this on other
platforms. That faint recollection also seems to point to it being
something to do with the marshalling of floats (.pyc files contain
constants in a marshalled form). Don't think I've ever seen it myself...

-------------------------------------------------------------------------
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: an*****@bullsey e.apana.org.au (pref) | Snail: PO Box 370
an*****@pcug.or g.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
Jul 21 '05 #2
[Donn Cave]
I ran into a phenomenon that seemed odd to me, while testing a
build of Python 2.4.1 on BeOS 5.04, on PowerPC 603e.

test_builtin.py , for example, fails a couple of tests with errors
claiming that apparently identical floating point values aren't equal.
But it only does that when imported, and only when the .pyc file
already exists. Not if I execute it directly (python test_builtin.py ),
or if I delete the .pyc file before importing it and running test_main().
It would be most helpful to open a bug report, with the output from
failing tests. Can't guess much from the above. In general, this can
happen if the platform C string<->float routines are so poor that

eval(repr(x)) != x

for some float x, because .pyc files store repr(x) for floats in
2.4.1. The 754 standard requires that eval(repr(x)) == x exactly for
all finite float x, and most platform C string<->float routines these
days meet that requirement.
For now, I'm going to just write this off as a flaky build. I would
be surprised if 5 people in the world care, and I'm certainly not one
of them. I just thought someone might find it interesting.
There are more than 5 numeric programmers even in the Python world
<wink>, but I'm not sure there are more than 5 such using BeOS 5.04 on
PowerPC 603e.
The stalwart few who still use BeOS are mostly using Intel x86 hardware,
as far as I know, but the first releases were for PowerPC, at first
on their own hardware and then for PPC Macs until Apple got nervous
and shut them out of the hardware internals. They use a Metrowerks
PPC compiler that of course hasn't seen much development in the last
6 years, probably a lot longer.


The ultimate cause is most likely in the platform C library's
string<->float routines (sprintf, strtod, that kind of thing).
Jul 21 '05 #3

"Tim Peters" <ti********@gma il.com> wrote in message
news:1f******** *************** @mail.gmail.com ...
[Donn Cave]
I ran into a phenomenon that seemed odd to me, while testing a
build of Python 2.4.1 on BeOS 5.04, on PowerPC 603e.

test_builtin.py , for example, fails a couple of tests with errors
claiming that apparently identical floating point values aren't equal.
But it only does that when imported, and only when the .pyc file
already exists. Not if I execute it directly (python test_builtin.py ),
or if I delete the .pyc file before importing it and running
test_main().

This is a known problem with marshalling INFs and/or NANs. *This* has
supposedly been fixed for 2.5. We are assuming that the failure you report
is for real floats.
It would be most helpful to open a bug report, with the output from
failing tests.
And assign to Tim.
In general, this can
happen if the platform C string<->float routines are so poor that

eval(repr(x)) != x .... The ultimate cause is most likely in the platform C library's
string<->float routines (sprintf, strtod, that kind of thing).


It would also be helpful if you could do some tests in plain C (no Python)
testing, for instance, the same values that failed. Hardly anyone else can
;-). If you confirm a problem with the C library, you can close the report
after opening, leaving it as a note for anyone else working with that
platform.

Terry J. Reedy

Jul 21 '05 #4
"Terry Reedy" <tj*****@udel.e du> writes:
"Tim Peters" <ti********@gma il.com> wrote in message
news:1f******** *************** @mail.gmail.com ...
[Donn Cave]
I ran into a phenomenon that seemed odd to me, while testing a
build of Python 2.4.1 on BeOS 5.04, on PowerPC 603e.

test_builtin.py , for example, fails a couple of tests with errors
claiming that apparently identical floating point values aren't equal.
But it only does that when imported, and only when the .pyc file
already exists. Not if I execute it directly (python test_builtin.py ),
or if I delete the .pyc file before importing it and running
test_main().
This is a known problem with marshalling INFs and/or NANs.
I hope you've also read all the bits and pieces where Tim says
"whatever happens to INFs and NANs is a platform dependent crapshoot".
We don't test platform dependent crapshoots in test_builtin (or at
least, I hope not!).
*This* has supposedly been fixed for 2.5.


Actually, it's likely that Donn's failure has been fixed for Python
2.5 as well, at least if Tim's guess is correct, because the C
string->float routines aren't invovled in loading .pycs any more.
It would be most helpful to open a bug report, with the output from
failing tests.


And assign to Tim.


That's mean! :)
In general, this can
happen if the platform C string<->float routines are so poor that

eval(repr(x)) != x

...
The ultimate cause is most likely in the platform C library's
string<->float routines (sprintf, strtod, that kind of thing).


It would also be helpful if you could do some tests in plain C (no Python)
testing, for instance, the same values that failed. Hardly anyone else can
;-). If you confirm a problem with the C library, you can close the report
after opening, leaving it as a note for anyone else working with that
platform.


I agree with this bit!

Cheers,
mwh

--
112. Computer Science is embarrassed by the computer.
-- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3745
by: Anton Noll | last post by:
We are using Visual Studio 2003.NET (C++) for the development of our software in the fields digital signal processing and numerical acoustics. One of our programs was working correctly if we are using the Debug-Version of the program, but it fails (or leads to false results) if we are using the Release-Version. After a long debugging session we found out, that our program was working correctly, but the floating point processing...
15
3931
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this the EPSILON? I know in float.h a FLT_EPSILON is defined to be 10^-5. Does this mean that the computer cannot distinguish between 2 numbers that differ by less than this epsilon?
14
2614
by: Robert Latest | last post by:
Hi guys, I'm sure this has been beaten to death on this newsgroup, but I can't find it in the CLC FAQ. Consider the following code: -------- double x = some_value_from_somewhere;
32
4111
by: ma740988 | last post by:
template <class T> inline bool isEqual( const T& a, const T& b, const T epsilon = std::numeric_limits<T>::epsilon() ) { const T diff = a - b; return ( diff <= epsilon ) && ( diff >= -epsilon ); } int main() { std::deque<double> pt ;
6
2440
by: yong321 | last post by:
With this script <script> alert(8/(3-8/3)) </script> I hope to get 24, but I get 23.99999999999999 in IE 6.0.2800 and Firefox 1.5.0.4. alert(6/(1-3/4)) returns 24 as expected. I see a number of threads in this newsgroup about the floating point
33
2768
by: dis_is_eagle | last post by:
hi....i have encountered strange problem regarding floating point comparison...the problem is... main() { float a=0.7; if(0.7 a) printf("hi"); else printf("hello");
70
3614
by: Robert Gamble | last post by:
9899:1999 5.1.2.3 Example 4 reads: "EXAMPLE 4 Implementations employing wide registers have to take care to honor appropriate semantics. Values are independent of whether they are represented in a register or in memory. For example, an implicit spilling of a register is not permitted to alter the value. Also, an explicit store and load is required to round to the precision of the storage type. In particular, casts and assignments are...
137
6678
by: mathieu.dutour | last post by:
Dear all, I want to do multiprecision floating point, i.e. I want to go beyond single precision, double precision and have quadruple precision, octuple precision and the like, and possibly with high speed. What would be the possible alternatives? Thanks for any help
9
5166
by: ssubbarayan | last post by:
Hi all, I am trying a program to convert floating point values to a byte array and printing the same to the screen.The idea behind this is we already have an existing function which can do byte level parsing what ever may be the type of data.The data would be coming from an external environment.When I parse int,char at byte level,I get right values,where as floating point just prints 0.000000 to the screen.Given below is a sample program...
0
8891
marktang
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...
0
9406
Oralloy
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...
0
9260
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9185
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,...
0
8103
agi2029
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...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3228
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
2
2639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.