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

Neil Girdhar mistersheik at gmail.com
Wed Feb 7 17:07:41 EST 2018


I wanted to have something like a binary floating point number like
0.11011.  Ideally, it would be as simple as Decimal('0.11011', radix=2).

Best,

Neil

On Wed, Feb 7, 2018 at 5:02 PM Chris Angelico <rosuav at gmail.com> wrote:

> On Thu, Feb 8, 2018 at 8:49 AM, Neil Girdhar <mistersheik at gmail.com>
> wrote:
> > Arbitrary radix comes up every now and then and Decimal already has a
> > radix() method.  It would be nice when initializing a Decimal object to
> be
> > able to specify an arbitrary radix>=2.
> >
>
> The radix method always returns 10, because decimal.Decimal always
> operates in base 10. Are you looking for a way to change the way
> arithmetic is done, or are you looking for a way to construct a
> Decimal from a string of digits and an arbitrary base (the way
> int("...", x) does)?
>
> ChrisA
> _______________________________________________
> 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/20180207/c1308ea1/attachment.html>


More information about the Python-ideas mailing list