Python2 distutils question: how to best "autoconfig"...?
Fredrik Lundh
fredrik at effbot.org
Mon Dec 11 14:37:40 EST 2000
Alex Martelli wrote:
> The specific issue is "how many bits of significance
> does a Python float have". (Or is there somewhere in
> the Python headers a #define for this that I missed...?)
why not just do things on the Python side? if not else,
it's a sure way to avoid optimization head-aches:
def get_base_and_digits():
def precise(x):
return x + 1.0 - x - 1.0 == 0.0
a = b = c = 1.0
base = digits = 0
while precise(a):
a = a + a
while not base:
b = b + b
base = a + b - a
while precise(c):
digits = digits + 1
c = c * base
return base, digits
>>> print get_base_and_digits()
(2.0, 53)
(if anyone runs Python on a box that returns anything
but (2.0, 53), let me know!)
</F>
More information about the Python-list
mailing list