factorial of negative one (-1)

Bj Raz whitequill.bj at gmail.com
Mon Nov 1 20:46:33 CET 2010


On Mon, Nov 1, 2010 at 8:52 AM, Bj Raz <whitequill.bj at gmail.com> wrote:

> On Nov 1, 2010, at 5:42 AM, Hrvoje Niksic <hniksic at xemacs.org> wrote:
>
> > Chris Rebert <clp2 at rebertia.com> writes:
> >
> >> (2) The underlying double-precision floating-point number only has ~16
> >> decimal digits of precision, so it's pointless to print out "further"
> >> digits.
> >
> > A digression which has nothing to do with Raj's desire for "better
> > accuracy"...
> >
> > Printing out further digits (without quotes) is not pointless if you
> > want to find out the exact representation of your number in python's
> > floating point, for educational purposes or otherwise.  Python has a
> > little-known but very instructive method for determining the makeup of a
> > float:
> >
> >>>> 1.1 .as_integer_ratio()
> > (2476979795053773, 2251799813685248)
> >
> > 1.1 is represented with the closest fraction with a power-of-two
> > denominator, 2476979795053773/2251799813685248.  As is the case with all
> > Python floats, this fraction has an exact decimal representation,
> > 1.100000000000000088817841970012523233890533447265625.  It is not that
> > unreasonable to request that the whole number be printed, and python
> > will happily oblige:
> >
> >>>> "%.100g" % 1.1
> > '1.100000000000000088817841970012523233890533447265625'
> >
> > The digits after the first cluster of zeros are not garbage, at least
> > not in the sense of what you get reading uninitialized memory and such;
> > they're mathematically precise decimal digits of the number that "1.1"
> > has turned into during conversion to float.
>
> Thank you Chris.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
Would "math.fsum" be of any use to me? and what is a good application of the
".as_integer_ratio()" for the out put?
Also I really just need the last number that starts to replete at the end of
each iteration. Is there a way to isolate that number that repeats a whole
bunch of times? Or at least cut off the output when it stops repeating?
So I get an output that looks like; "[0, -1.3333333333333333,
-1.2444444444444445, -1.2458553791887126, -1.2458468280690504,
-1.2458468531272766, -1.2458468530863318, -1.2458468530863729]" or
"[-1.2458468530863729]" and not:

[0, -1.3333333333333333, -1.2444444444444445, -1.2458553791887126,
-1.2458468280690504, -1.2458468531272766, -1.2458468530863318,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729,
-1.2458468530863729, -1.2458468530863729, -1.2458468530863729].
and when I am working with, other numbers; is there a way to get more
repetitions if I really need it?

Thank you everyone for all your suggestions and help. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101101/93d5aff6/attachment.html>


More information about the Python-list mailing list