[Python-ideas] Re: SupportsString Protocol Type Annotation

2020-10-08 Thread Serhiy Storchaka
07.10.20 18:43, Guido van Rossum пише: > Usability in a different context. > ``` z = 1j float(z) > Traceback (most recent call last): >   File "", line 1, in > TypeError: can't convert complex to float float(object()) > Traceback (most recent call last): >   File "", line 1, in > T

[Python-ideas] Exact decimal multiplication and division operations

2020-10-08 Thread Random832
I was making a "convert Fraction to Decimal, exactly if possible" function and ran into a wall: it's not possible to do some of the necessary operations with exact precision in decimal: - multiplication - division where the result can be represented exactly [the divisor is an integer whose prim

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Steven D'Aprano
On Thu, Oct 08, 2020 at 11:58:04AM -0400, Random832 wrote: > I was making a "convert Fraction to Decimal, exactly if possible" > function and ran into a wall: it's not possible to do some of the > necessary operations with exact precision in decimal: Of course you can't do them with *exact* pre

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Chris Angelico
On Fri, Oct 9, 2020 at 3:43 AM Steven D'Aprano wrote: > > On Thu, Oct 08, 2020 at 11:58:04AM -0400, Random832 wrote: > > > I was making a "convert Fraction to Decimal, exactly if possible" > > function and ran into a wall: it's not possible to do some of the > > necessary operations with exact pre

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Steven D'Aprano
On Fri, Oct 09, 2020 at 03:53:24AM +1100, Chris Angelico wrote: > On Fri, Oct 9, 2020 at 3:43 AM Steven D'Aprano wrote: > > > > On Thu, Oct 08, 2020 at 11:58:04AM -0400, Random832 wrote: > > > > > I was making a "convert Fraction to Decimal, exactly if possible" > > > function and ran into a wall:

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Tim Peters
[Random832 ] > I was making a "convert Fraction to Decimal, exactly if possible" function and > ran into a wall: it's not possible to do some of the necessary operations with > exact precision in decimal: > > - multiplication > - division where the result can be represented exactly [the divisor is

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Random832
On Thu, Oct 8, 2020, at 13:17, Tim Peters wrote: > [Random832 ] > > I was making a "convert Fraction to Decimal, exactly if possible" function > > and > > ran into a wall: it's not possible to do some of the necessary operations > > with > > exact precision in decimal: > > > > - multiplication >

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Random832
On Thu, Oct 8, 2020, at 13:12, Steven D'Aprano wrote: > I trimmed it because I didn't understand the relevance. If the > denominator is an exact multiple of only 2 and 5, then I think the > conversion will be exact if the precision is sufficient. I wanted the conversion to be exact irrespective

[Python-ideas] Re: Exact decimal multiplication and division operations

2020-10-08 Thread Tim Peters
[Random832] > I don't understand what's unclear - Obviously ;-) But without carefully constructed concrete use cases, what you say continues to remain unclear to me. > I was suggesting there should be an easy way to have the exact > result for all operations on Decimal operands that have exact r