[parisc-linux] Python math bug

Thibaut VARČNE varenet@esiee.fr
Tue, 8 Jan 2002 00:21:02 +0100


Hello,

After investigating a bit in an empirical way on the sqrt() function in 
python, I have noticed what seems to be a logical rule as follows:

All integer results (even when tested as X.0) are correct.
For the float numbers (I have only tested the X.X form), the rule looks 
like this:
the result for 0.X numbers is divided by (1/(2*sqrt(2))), ie multiplied 
by 2*sqrt(2)
for 1.X numbers, result is divided by sqrt(2)	(1 integer)
for 2.X and 3.X, divided by 2=(sqrt(2))^2		(2 different integers)
for 4.X -> 7.X, by (sqrt(2))^3				(4 different integers)
for 8.X -> 15.X, by 4=(sqrt(2))^4			(8 different integers)
for 16.X -> 31.X, by (sqrt(2))^5				(16 different integers)
for 32.X, by 8...

I have not tested further.

I have made the comparisons using a 10 digits (12 digits precision) 
calculator (as I had nothing else by this time).

I hope this will be useful for fixing the bug.


Thibaut
PA/Linux ESIEE Team