[Python-bugs-list] [ python-Bugs-721402 ] Random on PPC is outside acceptable range.
SourceForge.net
noreply@sourceforge.net
Mon, 14 Apr 2003 14:35:36 -0700
Bugs item #721402, was opened at 2003-04-14 16:43
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=721402&group_id=5470
Category: Extension Modules
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Kyle Wheeler (memoryhole)
Assigned to: Nobody/Anonymous (nobody)
Summary: Random on PPC is outside acceptable range.
Initial Comment:
On LinuxPPC, with gcc 2.96, python's (2.2.2) random function is outside the acceptable range. For example:
>>> import random
>>> print random.random()
1.35933812391
This random function, I believe, is supposed to produce numbers between 0 and 1.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2003-04-14 17:35
Message:
Logged In: YES
user_id=31435
Heh. Sorry about the "1.,0" -- that was a typo. "1.0" was
intended.
For the rest, floating mod is clearly broken in this Python,
and that's why random() is goofy (the last step in random() is
a fload mod). It's not broken on any platform I have, so I
can't be much help.
First thing to try is to recompile Python with optimizations
disabled. If it still fails, step thru floatobject.c's float_rem
function in a debugger and see where it's getting an insane
result.
If you know how to write C code, it could be that printing the
result of C
#import <math.h>
double x = fmod(1.35933812391, 1.0);
will show a bug instantly (in which case your C libm has the
bug).
----------------------------------------------------------------------
Comment By: Kyle Wheeler (memoryhole)
Date: 2003-04-14 17:19
Message:
Logged In: YES
user_id=17596
Python 2.2.2 (#1, Apr 13 2003, 16:19:28)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> print 1.35933812391 % 1,.0
1.35933812391 0.0
>>> print 1.35933812391 % 1.0
1.35933812391
>>> print 4%2
0
>>> print 1.3%2
3.3
Any ideas?
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2003-04-14 17:14
Message:
Logged In: YES
user_id=31435
What does the following statement print under this Python:
print 1.35933812391 % 1,.0
?
Note that there's almost no chance this is a bug in Python
(the implementation of random() hasn't changed in about 10
years). There's a good chance it's a bug in the specific C
compiler or C library release you're using.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=721402&group_id=5470