On Tue, 02 Oct 2007 06:07:15 +, Rhamphoryncus wrote:
> On Sep 30, 7:35 pm, andresj <[EMAIL PROTECTED]> wrote:
>> I was doing some programming in Python, and the idea came to my mind:
>> using fractions instead of floats when doing 2/5.
>
> The core problem wit
On Thu, 04 Oct 2007 02:47:27 -0700, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> > implementation in pure Python). Finally, arithmetic would become
>> > very confusing if there were three distinct numeric types; it already
>> > causes enough confusion with two!
>
> There's
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > implementation in pure Python). Finally, arithmetic would become very
> > confusing if there were three distinct numeric types; it already causes
> > enough confusion with two!
There's already ints, longs, floats, complexes, and decimals. What's
th
On Mon, 01 Oct 2007 09:09:21 -0700, Arnaud Delobelle wrote:
> As pointed out by others, implementations of rationals in Python abound.
> Whereas there is a canonical representation of floats and ints (and even
> longints) in the machine, it is not the case for rationals. Moreover
> most programmin
Neil Cerutti wrote:
>> Another guess could be that real numbers being closed under the
>> four arithmetic operations, there is no danger to accidentally
>> step into complex numbers. OTOH floats and rationals are two
>> (conflicting) ways of extending integers.
>
> You would have to adopt a few s
On Oct 2, 10:12?pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Tue, 02 Oct 2007 01:59:35 -0300, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> escribi :
>
> > How does gmpy make the conversion from float to rational?
>
> Well, you know, these days valuable software usually comes with something
En Tue, 02 Oct 2007 01:59:35 -0300, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> escribi�:
> How does gmpy make the conversion from float to rational?
Well, you know, these days valuable software usually comes with something
people call "documentation". Incomprehensible documents in strange formats
[EMAIL PROTECTED] wrote:
> On Oct 2, 1:12 am, Robert Kern <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>>> How does gmpy make the conversion from float to rational?
>> gmpy has a configurable transformation between floats and the internal
>> representation. I believe the default goes thr
On Oct 2, 5:43 pm, [EMAIL PROTECTED] wrote:
> On Oct 2, 5:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > But it is still wrong to say "0.6 is definitely not the same as 3/5".
>
> Out of context, I'd certainly agree. But from the context, I assumed
> it was clear that the 0.6 was a Pyt
On Oct 2, 5:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> But it is still wrong to say "0.6 is definitely not the same as 3/5".
Out of context, I'd certainly agree. But from the context, I assumed
it was clear that the 0.6 was a Python float. I probably should have
made this clearer.
On Oct 2, 1:12 am, Robert Kern <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Oct 1, 8:17?pm, [EMAIL PROTECTED] wrote:
> >> On Oct 1, 9:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> >>> On Oct 1, 7:20 pm, [EMAIL PROTECTED] wrote:
> On Oct 1, 8:30 am, Nick Craig-Wood <
On 2007-10-02, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Oct 2, 12:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>> > Scheme has prefix numeric operators, so that 1/2 is
>> > unambiguously (for the interpreter and the user) a lit
On Oct 2, 12:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> > Scheme has prefix numeric operators, so that 1/2 is
> > unambiguously (for the interpreter and the user) a litteral for
> > 'the fraction 1/2'. You can't avoid the confusion
On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Oct 1, 6:26 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>>
>> > Finally, arithmetic would become very confusing if there were
>> > three distinct numeric types; it already c
[EMAIL PROTECTED] wrote:
> On Oct 1, 8:17?pm, [EMAIL PROTECTED] wrote:
>> On Oct 1, 9:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>>
>>> On Oct 1, 7:20 pm, [EMAIL PROTECTED] wrote:
On Oct 1, 8:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> >>> mpq(1,3)+0.6
> mpq(14,1
On Sep 30, 7:35 pm, andresj <[EMAIL PROTECTED]> wrote:
> I was doing some programming in Python, and the idea came to my mind:
> using fractions instead of floats when doing 2/5.
The core problem with rationals (other than the inability to handle
irrationals) is their tendency to requ
On Oct 1, 8:17?pm, [EMAIL PROTECTED] wrote:
> On Oct 1, 9:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > On Oct 1, 7:20 pm, [EMAIL PROTECTED] wrote:
>
> > > On Oct 1, 8:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > > > >>> mpq(1,3)+0.6
> > > > mpq(14,15)
>
> > > Golly! T
"andresj" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
|| I know from __future__ import division changes the behaivour to return
| floats instead of ints, but what I meant is to be able to implement a
| function (or class/method) which would return what _I_ want/decide.
When you d
On Oct 1, 9:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Oct 1, 7:20 pm, [EMAIL PROTECTED] wrote:
>
> > On Oct 1, 8:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > > >>> mpq(1,3)+0.6
> > > mpq(14,15)
>
> > Golly! That's quite impressive. And more than a little bit magic
On Oct 1, 7:20 pm, [EMAIL PROTECTED] wrote:
> On Oct 1, 8:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > >>> mpq(1,3)+0.6
> > mpq(14,15)
>
> Golly! That's quite impressive. And more than a little bit magic as
> well, since 0.6 is definitely not the same as 3/5.
It's not? Since whe
On Oct 1, 7:09 pm, andresj <[EMAIL PROTECTED]> wrote:
> > > On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> > > > Finally, arithmetic would become very confusing if there were
> > > > three distinct numeric types; it already causes enough
> > > > confusion with two!
>
> Well, yeah...
On Oct 1, 8:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> >>> mpq(1,3)+0.6
> mpq(14,15)
Golly! That's quite impressive. And more than a little bit magic as
well, since 0.6 is definitely not the same as 3/5. How on earth does
this work?
Richard
--
http://mail.python.org/mailman/list
> > On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> > > Finally, arithmetic would become very confusing if there were
> > > three distinct numeric types; it already causes enough
> > > confusion with two!
Well, yeah... I get what you are saying, that would be confusing...
Terry Re
On Oct 1, 6:26 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> > Finally, arithmetic would become very confusing if there were
> > three distinct numeric types; it already causes enough
> > confusion with two!
>
> Scheme says: It's not th
On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> Finally, arithmetic would become very confusing if there were
> three distinct numeric types; it already causes enough
> confusion with two!
Scheme says: It's not that bad.
--
Neil Cerutti
I am free of all prejudices. I hate everyone e
On Oct 1, 2:35 am, andresj <[EMAIL PROTECTED]> wrote:
[snip Rational numbers in Python]
> I would like to get some feedback on this idea. Has this been posted
> before? If so, was it rejected? and for what?
> Also, I would like to know if you have improvements on the initial
> design, and if it w
On Sun, 30 Sep 2007 20:10:05 -0700, Andres Riofrio wrote:
[snip]
>>From what I've read, seems that the principal reason for rejecting the
> PEP is that there was not much need (enthusiasm)... Well, then I have a
> question: Is there a way to make 5/2 return something other than an
> integer? I can
Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> And gmpy: http://www.aleax.it/gmpy.html
And a concrete example
>>> from gmpy import mpq
>>> mpq(1,3)+mpq(0.4)
mpq(11,15)
>>> mpq(1,3)+mpq(4,10)
mpq(11,15)
>>> mpq(1,3)+mpq(6,10)
mpq(14,15)
>>> mpq(1,3)+0.6
mpq(14,15)
>>> mpq(5,2)
Andres Riofrio a écrit :
> Well, then I have
> a question: Is there a way to make 5/2 return something other than an
> integer?
>>> from __future__ import division
>>> 5/2
2.5
--
http://mail.python.org/mailman/listinfo/python-list
En Mon, 01 Oct 2007 00:10:05 -0300, Andres Riofrio
<[EMAIL PROTECTED]> escribi�:
> From what I've read, seems that the principal reason for rejecting the
> PEP is that there was not much need (enthusiasm)... Well, then I have
> a question: Is there a way to make 5/2 return something other than a
"Andres Riofrio" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| a question: Is there a way to make 5/2 return something other than an
| integer?
>>> from __future__ import division
>>> 1/2
0.5
>>> 5/2
2.5
tjr
--
http://mail.python.org/mailman/listinfo/python-list
En Sun, 30 Sep 2007 23:36:23 -0300, George Sakkis
<[EMAIL PROTECTED]> escribi�:
> On Sep 30, 9:35 pm, andresj <[EMAIL PROTECTED]> wrote:
>> I was doing some programming in Python, and the idea came to my mind:
>> using fractions instead of floats when doing 2/5.
35 pm, andresj <[EMAIL PROTECTED]> wrote:
> > I was doing some programming in Python, and the idea came to my mind: using
> > fractions instead of floats when doing 2/5.
> > (...)
> > I would like to get some feedback on this idea. Has this been posted
> > before?
On Sep 30, 9:35 pm, andresj <[EMAIL PROTECTED]> wrote:
> I was doing some programming in Python, and the idea came to my mind: using
> fractions instead of floats when doing 2/5.
> (...)
> I would like to get some feedback on this idea. Has this been posted
> before? If so,
On Sep 30, 8:35?pm, andresj <[EMAIL PROTECTED]> wrote:
> I was doing some programming in Python, and the idea came to my mind:
> using fractions instead of floats when doing 2/5.
>
> The problem arises when you try to represent some number, like 0.4 in
> a float. It will tel
On Sep 30, 6:48 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> andresj <[EMAIL PROTECTED]> writes:
> > The problem arises when you try to represent some number, like 0.4 in
> > a float.
>
> Which is really a specific case of the general problem that, for any
> given number base, some non-integer numbe
andresj <[EMAIL PROTECTED]> writes:
> The problem arises when you try to represent some number, like 0.4 in
> a float.
Which is really a specific case of the general problem that, for any
given number base, some non-integer numbers cannot be exactly
represented as fractions.
> Secondly, what hap
I was doing some programming in Python, and the idea came to my mind:
using fractions instead of floats when doing 2/5.
The problem arises when you try to represent some number, like 0.4 in
a float. It will tell you that it's equal to 0.40002.
"This is easy to fix", yo
38 matches
Mail list logo