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

2018-02-08 Thread Greg Ewing
Mark Dickinson wrote: And base-16 floating-point is still used in current IBM hardware, but I don't know whether that's purely for historical/backwards-compatibility reasons, or because it's faster for the FPU. Historically, base 16 was used to get a bigger exponent range for a given number

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

2018-02-08 Thread Mark Dickinson
On Wed, Feb 7, 2018 at 10:50 PM, Steven D'Aprano wrote: > Why? > > There are clear advantages to floating point arithmetic done in base 2 > (speed, minimum possible rounding error, least amount of wobble), and a > different advantage to floating point done in base 10

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

2018-02-07 Thread Neil Girdhar
That's really cool! I never knew about gmpy. On Wed, Feb 7, 2018 at 7:10 PM Case Van Horsen wrote: > On Wed, Feb 7, 2018 at 3:49 PM, Neil Girdhar > wrote: > > On Wed, Feb 7, 2018 at 6:36 PM Chris Angelico wrote: > >> You should be

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

2018-02-07 Thread Terry Reedy
On 2/7/2018 6:08 PM, Neil Girdhar wrote: On Wed, Feb 7, 2018 at 5:52 PM Steven D'Aprano > wrote: On Wed, Feb 07, 2018 at 10:08:50PM +, Neil Girdhar wrote: > Oh, and to answer your specific question, I want to change the way

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

2018-02-07 Thread Steven D'Aprano
On Wed, Feb 07, 2018 at 11:49:27PM +, Neil Girdhar wrote: > I see your list was about converting to and from base 10. That wasn't > really intended in my proposal. I meant wholly working in another base. > In that sense, 10 isn't particularly "fast, error-free, better at rounding, > etc."

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

2018-02-07 Thread Case Van Horsen
On Wed, Feb 7, 2018 at 3:49 PM, Neil Girdhar wrote: > On Wed, Feb 7, 2018 at 6:36 PM Chris Angelico 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

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

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 10:49 AM, Neil Girdhar wrote: >> > Right, I was playing with this problem >> > >> > (https://brilliant.org/weekly-problems/2017-10-02/advanced/?problem=no-computer-needed) >> > and wanted to work in base 2. I realize it's niche, but it's not >> >

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

2018-02-07 Thread Neil Girdhar
On Wed, Feb 7, 2018 at 6:36 PM Chris Angelico wrote: > On Thu, Feb 8, 2018 at 10:08 AM, Neil Girdhar > wrote: > > > > On Wed, Feb 7, 2018 at 5:52 PM Steven D'Aprano > wrote: > >> > >> - slower; > >> - larger errors when converting

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

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 10:08 AM, Neil Girdhar wrote: > > On Wed, Feb 7, 2018 at 5:52 PM Steven D'Aprano wrote: >> >> - slower; >> - larger errors when converting from decimal numbers (in general); >> - larger rounding errors; >> - larger wobble; > > >

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

2018-02-07 Thread Neil Girdhar
On Wed, Feb 7, 2018 at 5:52 PM Steven D'Aprano wrote: > On Wed, Feb 07, 2018 at 10:08:50PM +, Neil Girdhar wrote: > > > Oh, and to answer your specific question, I want to change the way > > arithmetic is done. I want it to be done in a different radix. > > Why? > >

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

2018-02-07 Thread Steven D'Aprano
On Wed, Feb 07, 2018 at 10:08:50PM +, Neil Girdhar wrote: > Oh, and to answer your specific question, I want to change the way > arithmetic is done. I want it to be done in a different radix. Why? There are clear advantages to floating point arithmetic done in base 2 (speed, minimum

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

2018-02-07 Thread Neil Girdhar
Oh, and to answer your specific question, I want to change the way arithmetic is done. I want it to be done in a different radix. On Wed, Feb 7, 2018 at 5:07 PM Neil Girdhar wrote: > I wanted to have something like a binary floating point number like > 0.11011. Ideally,

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

2018-02-07 Thread Neil Girdhar
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 wrote: > On Thu, Feb 8, 2018 at 8:49 AM, Neil Girdhar

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

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 8:49 AM, Neil Girdhar 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

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

2018-02-07 Thread Neil Girdhar
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. ___ Python-ideas mailing list Python-ideas@python.org