Re: On Numbers

2006-01-18 Thread Tom Anderson
On Wed, 18 Jan 2006, Steven D'Aprano wrote: > On Tue, 17 Jan 2006 23:34:40 +, Tom Anderson wrote: > So I don't really know what point you are making. What solution(s) for 1**0.5 were you expecting? >>> >>> He's probably getting at the fact that if you're dealing with complex >>> numb

Re: On Numbers

2006-01-18 Thread Erik Max Francis
Steve Holden wrote: > >>> import cmath > >>> cmath.sqrt(-1) > 1j > >>> > > Indeed. But even exponentiation can come respectably close: > > >>> (-1+0j)**0.5 > (6.123233995736766e-17+1j) Oh, no doubt. I was just pointing out that cmath.sqrt is what you want if you really do want the com

Re: On Numbers

2006-01-18 Thread Steve Holden
Erik Max Francis wrote: > Steven D'Aprano wrote: > > >>Perhaps you meant to write (-1)**0.5, in which case Python developers have >>a decision to make: should it assume real-valued maths unless explicitly >>told differently, and hence raise an exception, or coerce the result to >>complex? >> >>In

Re: On Numbers

2006-01-18 Thread Erik Max Francis
Steven D'Aprano wrote: > Perhaps you meant to write (-1)**0.5, in which case Python developers have > a decision to make: should it assume real-valued maths unless explicitly > told differently, and hence raise an exception, or coerce the result to > complex? > > In this case, Python raises an ex

Re: On Numbers

2006-01-18 Thread Steven D'Aprano
On Tue, 17 Jan 2006 23:34:40 +, Tom Anderson wrote: ... >>> So I don't really know what point you are making. What solution(s) for >>> 1**0.5 were you expecting? >> >> He's probably getting at the fact that if you're dealing with complex >> numbers, square root get a lot more complicated: >

Re: On Numbers

2006-01-17 Thread Tom Anderson
On Mon, 16 Jan 2006, Erik Max Francis wrote: > Steven D'Aprano wrote: > >> The square root of 1 is +1 (the negative root being explicitly >> rejected). Pure mathematicians, who may be expected to care whether the >> root is the integer 1 or the real number 1, are unlikely to write >> 1**0.5, pr

Re: On Numbers

2006-01-16 Thread Erik Max Francis
Steven D'Aprano wrote: > The square root of 1 is +1 (the negative root being > explicitly rejected). Pure mathematicians, who may be > expected to care whether the root is the integer 1 or > the real number 1, are unlikely to write 1**0.5, > prefering the squareroot symbol. > > For the rest o

Re: On Numbers

2006-01-16 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > So I don't really know what point you are making. What solution(s) for > 1**0.5 were you expecting? I think it was a sly way of saying "plus one or minus one". -- http://mail.python.org/mailman/listinfo/python-list

Re: On Numbers

2006-01-16 Thread Steven D'Aprano
Tom Anderson wrote: > On Sun, 15 Jan 2006, Alex Martelli wrote: > >> Paul Rubin wrote: >> >>> Mike Meyer <[EMAIL PROTECTED]> writes: >>> I'd like to work on that. The idea would be that all the numeric types are representations of reals with different propert

Re: On Numbers

2006-01-16 Thread Tom Anderson
On Sun, 15 Jan 2006, Alex Martelli wrote: > Paul Rubin wrote: > >> Mike Meyer <[EMAIL PROTECTED]> writes: >> >>> I'd like to work on that. The idea would be that all the numeric types >>> are representations of reals with different properties that make them >>> appropr

Re: On Numbers

2006-01-16 Thread Alex Martelli
Terry Hancock <[EMAIL PROTECTED]> wrote: ... > I'm bothered by the fact that "int" can be coerced into > either "decimal" or "float". In practice, you should > have to choose one or the other. Practically speaking, Why ever?! You're indicating "is a subset of", and int IS a subset of both (ne

Re: On Numbers

2006-01-16 Thread Terry Hancock
On 15 Jan 2006 21:14:33 -0800 "Dan Bishop" <[EMAIL PROTECTED]> wrote: > although I personally would prefer > >(number) >/ \ > (realnumber) complex > | | | > int float | > | > Decimal Mathematically, "real numbers" are a subset of "complex numbers",

Re: On Numbers

2006-01-15 Thread Dan Bishop
Alex Martelli wrote: > Paul Rubin wrote: > > > Mike Meyer <[EMAIL PROTECTED]> writes: > > > I'd like to work on that. The idea would be that all the numeric types > > > are representations of reals with different properties that make them > > > appropriate for different u

Re: On Numbers

2006-01-15 Thread Alex Martelli
Paul Rubin wrote: > Mike Meyer <[EMAIL PROTECTED]> writes: > > I'd like to work on that. The idea would be that all the numeric types > > are representations of reals with different properties that make them > > appropriate for different uses. > > 2+3j? Good point, so

Re: On Numbers

2006-01-15 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes: > I'd like to work on that. The idea would be that all the numeric types > are representations of reals with different properties that make them > appropriate for different uses. 2+3j? -- http://mail.python.org/mailman/listinfo/python-list

Re: On Numbers

2006-01-14 Thread Bengt Richter
On Sat, 14 Jan 2006 18:18:12 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: >In the discussion of equality, the issue that decimal('3.0') == 3.0 is >False came up as a reason for changing the behavior of ==. The problem >with this is that the proposed change doesn't really fix anything, it >just giv

Re: On Numbers

2006-01-14 Thread Dan Sommers
On Sat, 14 Jan 2006 18:18:12 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: > ... the proposed change doesn't really fix anything, it just gives > different wrong behavior ... :-) > To get started on that, I want to consider how other languages with > rich numeric type systems model them. I'm goi