Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30961

Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?

References <91ff9b33-c212-4be0-8ed0-1f6b16f56865@googlegroups.com> <5072E7CC.2070405@davea.name>
Date 2012-10-09 02:00 +1100
Subject Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1953.1349708407.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Oct 9, 2012 at 1:48 AM, Dave Angel <d@davea.name> wrote:
> import decimal
> a = decimal.Decimal(4.3)
> print(a)
>
> 5.0999999999999996447286321199499070644378662109375

Ah, the delights of copy-paste :)

> The Decimal class has the disadvantage that it's tons slower on any modern machine I know of...

Isn't it true, though, that Python 3.3 has a completely new
implementation of decimal that largely removes this disadvantage?

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? iMath <redstone-cold@163.com> - 2012-10-08 07:07 -0700
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Dave Angel <d@davea.name> - 2012-10-08 10:48 -0400
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Chris Angelico <rosuav@gmail.com> - 2012-10-09 02:00 +1100
    Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm � Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-09 11:39 +0000
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Dave Angel <d@davea.name> - 2012-10-08 11:13 -0400
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-08 16:44 +0200
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Chris Angelico <rosuav@gmail.com> - 2012-10-09 02:19 +1100
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Terry Reedy <tjreedy@udel.edu> - 2012-10-08 21:45 -0400
  Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ? Dave Angel <d@davea.name> - 2012-10-08 22:20 -0400

csiph-web