[Python-ideas] Consider generalizing Decimal to support arbitrary radix

Neil Girdhar mistersheik at gmail.com
Wed Feb 7 19:14:42 EST 2018


That's really cool!  I never knew about gmpy.

On Wed, Feb 7, 2018 at 7:10 PM Case Van Horsen <casevh at gmail.com> wrote:

> On Wed, Feb 7, 2018 at 3:49 PM, Neil Girdhar <mistersheik at gmail.com>
> wrote:
> > On Wed, Feb 7, 2018 at 6:36 PM Chris Angelico <rosuav at gmail.com> wrote:
> >> You should be able to use the native float type for binary
> >> floating-point. But the whole point of that challenge is that you
> >> shouldn't need a computer.
> >
> >
> > Yeah, I know, but I wanted to play with it.  Anyway, native floats don't
> > help.
> >>
> >>
> >> ChrisA
>
> I maintain gmpy2 and it might do what you want (arbitrary precision
> radix-2 arithmetic and easy access to the bits).
>
> >>> gmpy2.get_context().precision=70
> >>> gmpy2.mpfr(1)/7
> mpfr('0.14285714285714285714283',70)
> >>> (gmpy2.mpfr(1)/7).digits(2)
> ('1001001001001001001001001001001001001001001001001001001001001001001001',
> -2, 70)
>
> Historical memory - I once wrote a radix-6 fixed point library to
> explore an extension of the 3n+1 problem to rational numbers. It was
> written in Turbo Pascal and ran for days on a 286/287 PC.
>
> casevh
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/twWEvFwahaQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180208/f88375b4/attachment-0001.html>


More information about the Python-ideas mailing list