Re: Precision Tail-off?

2023-02-18 Thread Oscar Benjamin
On Sat, 18 Feb 2023 at 11:19, Peter J. Holzer wrote: > > On 2023-02-18 03:52:51 +, Oscar Benjamin wrote: > > On Sat, 18 Feb 2023 at 01:47, Chris Angelico wrote: > > > On Sat, 18 Feb 2023 at 12:41, Greg Ewing via Python-list > > > > To avoid it you would need to use an algorithm that computes

Re: Precision Tail-off?

2023-02-18 Thread Peter J. Holzer
On 2023-02-18 03:52:51 +, Oscar Benjamin wrote: > On Sat, 18 Feb 2023 at 01:47, Chris Angelico wrote: > > On Sat, 18 Feb 2023 at 12:41, Greg Ewing via Python-list > > > To avoid it you would need to use an algorithm that computes nth > > > roots directly rather than raising to the power 1/n.

Re: Precision Tail-off?

2023-02-17 Thread Oscar Benjamin
On Sat, 18 Feb 2023 at 01:47, Chris Angelico wrote: > > On Sat, 18 Feb 2023 at 12:41, Greg Ewing via Python-list > wrote: > > > > On 18/02/23 7:42 am, Richard Damon wrote: > > > On 2/17/23 5:27 AM, Stephen Tucker wrote: > > >> None of the digits in RootNZZZ's string should be different from the

Re: Precision Tail-off?

2023-02-17 Thread Michael Torrie
On 2/17/23 15:03, Grant Edwards wrote: > Every fall, the groups were again full of a new crop of people who had > just discovered all sorts of bugs in the way > implemented floating point, and pointing them to a nicely written > document that explained it never did any good. But to be fair,

Re: Precision Tail-off?

2023-02-17 Thread Chris Angelico
On Sat, 18 Feb 2023 at 12:41, Greg Ewing via Python-list wrote: > > On 18/02/23 7:42 am, Richard Damon wrote: > > On 2/17/23 5:27 AM, Stephen Tucker wrote: > >> None of the digits in RootNZZZ's string should be different from the > >> corresponding digits in RootN. > > > > Only if the storage

Re: Precision Tail-off?

2023-02-17 Thread Greg Ewing via Python-list
On 18/02/23 7:42 am, Richard Damon wrote: On 2/17/23 5:27 AM, Stephen Tucker wrote: None of the digits in RootNZZZ's string should be different from the corresponding digits in RootN. Only if the storage format was DECIMAL. Note that using decimal wouldn't eliminate this particular problem,

Re: Precision Tail-off?

2023-02-17 Thread Grant Edwards
On 2023-02-17, Mats Wichmann wrote: > And... this topic as a whole comes up over and over again, like > everywhere. That's an understatement. I remember it getting rehashed over and over again in various USENET groups 35 years ago when when the VAX 11/780 BSD machine on which I read news

Re: Precision Tail-off?

2023-02-17 Thread Mats Wichmann
On 2/17/23 11:42, Richard Damon wrote: On 2/17/23 5:27 AM, Stephen Tucker wrote: The key factor here is IEEE floating point is storing numbers in BINARY, not DECIMAL, so a multiply by 1000 will change the representation of the number, and thus the possible resolution errors. Store you

Re: Precision Tail-off?

2023-02-17 Thread Grant Edwards
On 2023-02-17, Richard Damon wrote: > [...] > >> Perhaps this observation should be brought to the attention of the IEEE. I >> would like to know their response to it. > > That is why they have developed the Decimal Floating point format, to > handle people with those sorts of problems. > > They

Re: Precision Tail-off?

2023-02-17 Thread Peter J. Holzer
On 2023-02-17 14:39:42 +, Weatherby,Gerard wrote: > IEEE did not define a standard for floating point arithmetics. They > designed multiple standards, including a decimal float point one. > Although decimal floating point (DFP) hardware used to be > manufactured, I couldn’t find any current

Re: Precision Tail-off?

2023-02-17 Thread Peter J. Holzer
On 2023-02-17 10:27:08 +, Stephen Tucker wrote: > This is a hugely controversial claim, I know, but I would consider this > behaviour to be a serious deficiency in the IEEE standard. > > Consider an integer N consisting of a finitely-long string of digits in > base 10. > > Consider the

Re: Precision Tail-off?

2023-02-17 Thread Peter J. Holzer
On 2023-02-17 08:38:58 -0700, Michael Torrie wrote: > On 2/17/23 03:27, Stephen Tucker wrote: > > Thanks, one and all, for your reponses. > > > > This is a hugely controversial claim, I know, but I would consider this > > behaviour to be a serious deficiency in the IEEE standard. > > No matter

Re: Precision Tail-off?

2023-02-17 Thread Oscar Benjamin
On Fri, 17 Feb 2023 at 10:29, Stephen Tucker wrote: > > Thanks, one and all, for your reponses. > > This is a hugely controversial claim, I know, but I would consider this > behaviour to be a serious deficiency in the IEEE standard. [snip] > > Perhaps this observation should be brought to the

Re: Precision Tail-off?

2023-02-17 Thread Richard Damon
On 2/17/23 5:27 AM, Stephen Tucker wrote: Thanks, one and all, for your reponses. This is a hugely controversial claim, I know, but I would consider this behaviour to be a serious deficiency in the IEEE standard. Consider an integer N consisting of a finitely-long string of digits in base 10.

Re: Precision Tail-off?

2023-02-17 Thread Michael Torrie
On 2/17/23 03:27, Stephen Tucker wrote: > Thanks, one and all, for your reponses. > > This is a hugely controversial claim, I know, but I would consider this > behaviour to be a serious deficiency in the IEEE standard. No matter how you do it, there are always tradeoffs and inaccuracies moving

Re: Precision Tail-off?

2023-02-17 Thread Peter Pearson
On Fri, 17 Feb 2023 10:27:08, Stephen Tucker wrote:[Head-posting undone.] > On Thu, Feb 16, 2023 at 6:49 PM Peter Pearson > wrote: >> On Tue, 14 Feb 2023 11:17:20 +, Oscar Benjamin wrote: >> > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker >> wrote: >> [snip] >> >> I have just produced the

RE: Precision Tail-off?

2023-02-17 Thread avi.e.gross
? -Original Message- From: Python-list On Behalf Of Stephen Tucker Sent: Friday, February 17, 2023 5:27 AM To: python-list@python.org Subject: Re: Precision Tail-off? Thanks, one and all, for your reponses. This is a hugely controversial claim, I know, but I would consider this behaviour

Re: Precision Tail-off?

2023-02-17 Thread Weatherby,Gerard
until a few years ago, but they seem to have gone dark: https://twitter.com/SilMinds From: Python-list on behalf of Thomas Passin Date: Friday, February 17, 2023 at 9:02 AM To: python-list@python.org Subject: Re: Precision Tail-off? *** Attention: This is an external email. Use caution

Re: Precision Tail-off?

2023-02-17 Thread Thomas Passin
On 2/17/2023 5:27 AM, Stephen Tucker wrote: Thanks, one and all, for your reponses. This is a hugely controversial claim, I know, but I would consider this behaviour to be a serious deficiency in the IEEE standard. Consider an integer N consisting of a finitely-long string of digits in base

Re: Precision Tail-off?

2023-02-17 Thread Stephen Tucker
As a follow-up to my previous message, I have just produced the following log on IDLE, for your information: -- >>> math.e ** (math.log (12345678900) / 3) 4.979338592181741e+16 >>> 10 ** (math.log10

Re: Precision Tail-off?

2023-02-17 Thread Stephen Tucker
Thanks, one and all, for your reponses. This is a hugely controversial claim, I know, but I would consider this behaviour to be a serious deficiency in the IEEE standard. Consider an integer N consisting of a finitely-long string of digits in base 10. Consider the infinitely-precise cube root

Re: Precision Tail-off?

2023-02-16 Thread Peter Pearson
On Tue, 14 Feb 2023 11:17:20 +, Oscar Benjamin wrote: > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker wrote: [snip] >> I have just produced the following log in IDLE (admittedly, in Python >> 2.7.10 and, yes I know that it has been superseded). >> >> It appears to show a precision tail-off as

Re: Precision Tail-off?

2023-02-15 Thread Weatherby,Gerard
) 8.881784197001252e-16 1E-99 From: Python-list on behalf of Michael Torrie Date: Tuesday, February 14, 2023 at 5:52 PM To: python-list@python.org Subject: Re: Precision Tail-off? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On 2

Re: Precision Tail-off?

2023-02-14 Thread Michael Torrie
On 2/14/23 00:09, Stephen Tucker wrote: > I have two questions: > 1. Is there a straightforward explanation for this or is it a bug? To you 1/3 may be an exact fraction, and the definition of raising a number to that power means a cube root which also has an exact answer, but to the computer, 1/3

Re: Precision Tail-off?

2023-02-14 Thread Weatherby,Gerard
Use Python3 Use the decimal module: https://docs.python.org/3/library/decimal.html From: Python-list on behalf of Stephen Tucker Date: Tuesday, February 14, 2023 at 2:11 AM To: Python Subject: Precision Tail-off? *** Attention: This is an external email. Use caution responding, opening

Re: Precision Tail-off?

2023-02-14 Thread Oscar Benjamin
On Tue, 14 Feb 2023 at 07:12, Stephen Tucker wrote: > > Hi, > > I have just produced the following log in IDLE (admittedly, in Python > 2.7.10 and, yes I know that it has been superseded). > > It appears to show a precision tail-off as the supplied float gets bigger. > > I have two questions: >

Re: Precision reading and writing data frames to csv

2017-03-11 Thread Paulo da Silva
Às 23:29 de 11-03-2017, Erik escreveu: > Hi Paulo, > > On 11/03/17 22:01, Paulo da Silva wrote: ... >> Now my question is: Is it possible the occurrence of successive >> cumulative errors? I mean reading a file, adding lines or change few >> ones but keeping the most of the other lines untouched

Re: Precision reading and writing data frames to csv

2017-03-11 Thread Erik
Hi Paulo, On 11/03/17 22:01, Paulo da Silva wrote: I have a dir with lots of csv files. These files are updated +- once a day. I could see that some values are converted, during output, to very close values but with lots of digits. I understand that is caused by the internal bits'

Re: Precision reading and writing data frames to csv

2017-03-11 Thread MRAB
On 2017-03-11 22:01, Paulo da Silva wrote: Hi! I have a dir with lots of csv files. These files are updated +- once a day. I could see that some values are converted, during output, to very close values but with lots of digits. I understand that is caused by the internal bits' representation of

Re: Precision issue in python

2010-02-20 Thread Mark Dickinson
On Feb 20, 11:17 am, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: Hello everyone. I think it is  related to the precision with double arithmetic so i posted here.I am trying with this problem (https://www.spoj.pl/problems/CALCULAT) and the problem say that Note : for all test cases whose

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
A quick solution I came out with, no stirling numbers and had tried to avoid large integer multiplication as much as possible. import math for i in range(int(raw_input())): n, k, l = [int(i) for i in raw_input().split()] e = sum(math.log10(i) for i in range(1, n+1)) frac_e = e -

Re: Precision issue in python

2010-02-20 Thread mukesh tiwari
On Feb 20, 5:44 pm, Mark Dickinson dicki...@gmail.com wrote: On Feb 20, 11:17 am, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: Hello everyone. I think it is  related to the precision with double arithmetic so i posted here.I am trying with this problem

Re: Precision issue in python

2010-02-20 Thread mukesh tiwari
On Feb 20, 8:13 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: On Feb 20, 5:44 pm, Mark Dickinson dicki...@gmail.com wrote: On Feb 20, 11:17 am, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: Hello everyone. I think it is  related to the precision with double arithmetic

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
I don't know if is possible to import this decimal module but kindly tell me.Also a bit about log implementation Why don't you read about decimal module (there is log too in it) and try writing your approach here in case it does not work? Or you insist someone to rewrite your code using decimal

Re: Precision issue in python

2010-02-20 Thread Mark Dickinson
On Feb 20, 3:37 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: I don't know if is possible to import this decimal module but kindly tell me.Also a bit about log implementation The decimal module is part of the standard library; I don't know what the rules are for SPOJ, but you're

Re: Precision issue in python

2010-02-20 Thread Mark Dickinson
On Sat, Feb 20, 2010 at 2:42 PM, Shashwat Anand anand.shash...@gmail.com wrote: A quick solution I came out with, no stirling numbers and had tried to avoid large integer multiplication as much as possible. import math for i in range(int(raw_input())):     n, k, l = [int(i) for i in

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
@Mark, The str(...).split('.') here doesn't do a good job of extracting the integer part when its argument is = 1e12, since Python produces a result in scientific notation. I think you're going to get strange results when k = 13. Yeah, you were correct. I tested it for k = 13, and there

Re: Precision for equality of two floats?

2005-11-29 Thread Bengt Richter
On Mon, 28 Nov 2005 07:58:37 -0800, [EMAIL PROTECTED] (Alex Martelli) wrote: Anton81 [EMAIL PROTECTED] wrote: Hi! When I do simple calculation with float values, they are rarely exactly equal even if they should be. What is the threshold and how can I change it? Python's builtin floats

Re: Precision for equality of two floats?

2005-11-29 Thread gene tani
Anton81 wrote: Hi! When I do simple calculation with float values, they are rarely exactly equal even if they should be. What is the threshold and how can I change it? e.g. if f1==f2: will always mean if abs(f1-f2)1e-6: Anton googled for floating point comparison tolerance

Re: Precision for equality of two floats?

2005-11-29 Thread Dan Sommers
On Tue, 29 Nov 2005 14:31:46 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote: On Mon, 28 Nov 2005 07:58:37 -0800, [EMAIL PROTECTED] (Alex Martelli) wrote: Python's builtin floats compare for exact bit-by-bit equality -- no threshold. You may want to look at the allclose function in the Does

Re: Precision for equality of two floats?

2005-11-28 Thread Alex Martelli
Anton81 [EMAIL PROTECTED] wrote: Hi! When I do simple calculation with float values, they are rarely exactly equal even if they should be. What is the threshold and how can I change it? Python's builtin floats compare for exact bit-by-bit equality -- no threshold. You may want to look at

Re: Precision for equality of two floats?

2005-11-28 Thread Fredrik Lundh
Anton81 wrote: When I do simple calculation with float values, they are rarely exactly equal even if they should be. What is the threshold http://www.lahey.com/float.htm http://docs.python.org/tut/node16.html and how can I change it? you cannot. e.g. if f1==f2: will always mean if

Re: Precision for equality of two floats?

2005-11-28 Thread Mike Meyer
Anton81 [EMAIL PROTECTED] writes: When I do simple calculation with float values, they are rarely exactly equal even if they should be. What is the threshold and how can I change it? Implementation dependent, because floats use an underlying C type, and there's no portable way to do that.

Re: Precision for equality of two floats?

2005-11-28 Thread Steven D'Aprano
On Mon, 28 Nov 2005 12:35:16 -0500, Mike Meyer wrote: e.g. if f1==f2: will always mean if abs(f1-f2)1e-6: This is a *bad* idea. What happens if f1=1e-12 and f2=1e-112? Do you really want to values that 100 orders of magnitude different to compare as equal? Sure, if f1 and f2 represent

Re: precision problems in base conversion of rational numbers

2005-07-07 Thread [EMAIL PROTECTED]
Raymond Hettinger wrote: For a simple example, convert both 10247448370872321 and 10247448370872319 from base ten to 4 digits of hex. The calculations need to be carried out to 15 places of hex (or 17 places of decimal) just to determine whether the fourth hex digit is a 7 or 8:

Re: precision problems in base conversion of rational numbers

2005-07-06 Thread Raymond Hettinger
[Terry Hancock] Needless to say, the conventional floating point numbers in Python are actually stored as *binary*, which is why there is a decimal module (which is new). If you're going to be converting between bases anyway, it probably makes little difference whether you are using

Re: precision problems in base conversion of rational numbers

2005-07-06 Thread [EMAIL PROTECTED]
Raymond Hettinger wrote: [Terry Hancock] Needless to say, the conventional floating point numbers in Python are actually stored as *binary*, which is why there is a decimal module (which is new). If you're going to be converting between bases anyway, it probably makes little

Re: precision problems in base conversion of rational numbers

2005-07-06 Thread Raymond Hettinger
For a simple example, convert both 10247448370872321 and 10247448370872319 from base ten to 4 digits of hex. The calculations need to be carried out to 15 places of hex (or 17 places of decimal) just to determine whether the fourth hex digit is a 7 or 8: hex(10247448370872321)

Re: precision problems in base conversion of rational numbers

2005-07-05 Thread Terry Hancock
On Monday 04 July 2005 06:11 am, Brian van den Broek wrote: As a self-directed learning exercise I've been working on a script to convert numbers to arbitrary bases. It aims to take any of whole numbers (python ints, longs, or Decimals), rational numbers (n / m n, m whole) and floating

Re: precision problems in base conversion of rational numbers

2005-07-05 Thread [EMAIL PROTECTED]
Brian van den Broek wrote: Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a script to convert numbers to arbitrary bases. It aims to take any of whole

Re: precision problems in base conversion of rational numbers

2005-07-05 Thread Brian van den Broek
Terry Hancock said unto the world upon 05/07/2005 11:49: On Monday 04 July 2005 06:11 am, Brian van den Broek wrote: As a self-directed learning exercise I've been working on a script to convert numbers to arbitrary bases. It aims to take any of whole numbers (python ints, longs, or

Re: precision problems in base conversion of rational numbers

2005-07-05 Thread Dan Bishop
Brian van den Broek wrote: Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a script to convert numbers to arbitrary bases. It aims to take any of whole

Re: Precision?

2005-05-16 Thread Steffen Glückselig
So for using the python-interpreter as a simple calculator using 'print' seems to be the simplest and still exact way... Thanks for clarification Steffen -- http://mail.python.org/mailman/listinfo/python-list

Re: Precision?

2005-05-15 Thread Steven Bethard
tiissa wrote: Steffen Glückselig wrote: 1.0 + 3.0 + 4.6 8.5996 Ehm, how could I get the intuitively 'correct' result of - say - 8.6? ;-) You may find annex B of the python tutorial an interesting read: http://docs.python.org/tut/node16.html Yes, the simplest way to get

Re: Precision?

2005-05-15 Thread Ron Adam
tiissa wrote: Steffen Glückselig wrote: 1.0 + 3.0 + 4.6 8.5996 Ehm, how could I get the intuitively 'correct' result of - say - 8.6? ;-) You may find annex B of the python tutorial an interesting read: http://docs.python.org/tut/node16.html In addition to what you find in

Re: Precision?

2005-05-15 Thread Jeff Epler
If you want to do decimal arithmetic, use the decimal module which is new in Python 2.4. Python 2.4 (#1, Jan 22 2005, 20:45:18) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 Type help, copyright, credits or license for more information. from decimal import Decimal as D D(1.0) + D(3.0)

Re: Precision?

2005-05-15 Thread Peter Dembinski
Steffen Glckselig [EMAIL PROTECTED] writes: Hello, I've just wanted to check Python's abilities as a calculator and this is what came out: 1.0 + 3.0 + 4.6 8.5996 Ehm, how could I get the intuitively 'correct' result of - say - 8.6? ;-) This is as correct as your computer's

Re: Precision?

2005-05-15 Thread Facundo Batista
On 5/15/05, Ron Adam [EMAIL PROTECTED] wrote: x 321.61 Here the error has been kept to a minimum. In most cases, it isn't a problem, but it is something to be aware of. It does matter in banking and I beleive there are standard ways of dealing with it. Yes, use Decimal: