Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
False
Square root of 2 is not a rational number.
Nobody said it
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 measurement.
On Thu, 03 Jul 2014 09:51:35 +0300, Marko Rauhamaa wrote:
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
[...]
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
Steven D'Aprano st...@pearwood.info:
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
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.
1-0.95
0.050044
How to get 0.05 as result?
Oh
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
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*
On Wed, Jul 2, 2014 at 11:59 AM, Marko Rauhamaa ma...@pacujo.net 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
--
On Wed, 02 Jul 2014 19:59:25 +0300, Marko Rauhamaa wrote:
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
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
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
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
On Thu, Jul 3, 2014 at 6:00 AM, Marko Rauhamaa ma...@pacujo.net wrote:
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
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
On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
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.
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
wink
Just as there are even some esteemed
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
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 be (c - a)
On Wed, Jul 2, 2014 at 10:55 PM, Gregory Ewing
greg.ew...@canterbury.ac.nz 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.
--
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 result?
bc has scale=2 . Has Python some similar feature?
--
https
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
How to get 0.05 as result?
bc has scale=2
Pedro Izecksohn izecks...@yahoo.com 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.050044
How to get 0.05 as result?
print(%4.2f%(1
18 matches
Mail list logo