Steven D'Aprano :
> If you don't think Fraction counts as "arbitrary precision rational
> number", what do you think does?
I was assuming you were referring to an idealized datatype.
Fraction() doesn't have a square root method. Let's make one:
def newton(x, n):
guess = Fraction(1)
On Thu, 03 Jul 2014 09:51:35 +0300, Marko Rauhamaa wrote:
> Steven D'Aprano :
[...]
>> By the way, there's no need to use an invented example. Here is an
>> actual example:
>>
>> py> import math
>> py> from fractions import Fraction
>> py> math.sqrt(Fraction(2))**2
>> 2.0004
>
> Sure,
On Wed, 02 Jul 2014 21:06:52 -0700, Rustom Mody wrote:
> On Thursday, July 3, 2014 7:49:30 AM UTC+5:30, Steven D'Aprano wrote:
>> On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
>
>> > On the other hand, floating-point numbers are perfect whenever you
>> > deal with science and measurem
Steven D'Aprano :
> On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
>> Steven D'Aprano :
>>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
False
>>> Square root of 2 is not a rational number.
>> Nobody said it was.
>
> Your comment can be read as implying it. Yo
On Wed, Jul 2, 2014 at 10:55 PM, Gregory Ewing
wrote:
> Although loss of precision might give you the
> right answer anyway. :-)
There aren't that many digits in the speed of light. Unless we're
talking about a very, very slow-moving automobile.
--
https://mail.python.org/mailman/listinfo/pytho
On Thursday, July 3, 2014 10:25:17 AM UTC+5:30, Gregory Ewing wrote:
> Rustom Mody wrote:
> > Just as there are even some esteemed members of this list who think
> > that c - a is a meaningful operation
> > where
> > c is speed of light
> > a is speed of an automobile
> Indeed, it should
Rustom Mody wrote:
Just as there are even some esteemed members of this list who think
that c - a is a meaningful operation
where
c is speed of light
a is speed of an automobile
Indeed, it should be (c - a) / (1 - (c*a)/c**2).
Although loss of precision might give you the
right answer
On Thursday, July 3, 2014 7:49:30 AM UTC+5:30, Steven D'Aprano wrote:
> On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
> > On the other hand, floating-point numbers are perfect whenever you deal
> > with science and measurement.
> /head-desk
Just as there are even some esteemed mem
On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>>>>>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
>>>False
>>
>> Square root of 2 is not a rational number.
>
> Nobody said it was.
Your comment can be read as implying it. You stated:
[quo
On Thu, Jul 3, 2014 at 6:00 AM, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>>>>>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
>>>False
>>
>> Square root of 2 is not a rational number.
>
> Nobody said it was. It's just that even "arbitrary-precision" rational
> numbers wouldn't
Steven D'Aprano :
>>>>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
>>False
>
> Square root of 2 is not a rational number.
Nobody said it was. It's just that even "arbitrary-precision" rational
numbers wouldn't free you from the issues of floating-point numbers. The
Decimal num
On Wed, 02 Jul 2014 19:59:25 +0300, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>> This is a problem with the underlying C double floating point format.
>> Actually, it is not even a problem with the C format, since this
>> problem applies to ANY floating point format, consequently this sort of
>
On Wed, Jul 2, 2014 at 11:59 AM, Marko Rauhamaa wrote:
> Yes, I'm making it up, but it's still true.
I don't think there's any reason to be hypothetical:
In [149]: d
Out[149]: Decimal('2')
In [150]: d.sqrt() * d.sqrt() == d
Out[150]: False
:-)
Skip
--
https://mail.python.org/mailman/listinfo
Steven D'Aprano :
> This is a problem with the underlying C double floating point format.
> Actually, it is not even a problem with the C format, since this
> problem applies to ANY floating point format, consequently this sort
> of thing plagues *every* programming language (unless they use
> arb
On Tue, 01 Jul 2014 14:17:14 -0700, Pedro Izecksohn wrote:
> pedro@microboard:~$ /usr/bin/python3
> Python 3.3.2+ (default, Feb 28 2014, 00:52:16) [GCC 4.8.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>&
Pedro Izecksohn writes:
> pedro@microboard:~$ /usr/bin/python3
> Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
> [GCC 4.8.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> 1-0.95
> 0.0500
On 01/07/2014 22:17, Pedro Izecksohn wrote:
pedro@microboard:~$ /usr/bin/python3
Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
1-0.95
0.050044
pedro@microboard:~$ /usr/bin/python3
Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1-0.95
0.050044
>>>
How to get 0.05 as r
18 matches
Mail list logo