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


Groups > comp.lang.python > #30963

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

From Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Newsgroups comp.lang.python
Subject Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?
Date 2012-10-08 16:44 +0200
Message-ID <he5bk9-e3p.ln1@satorlaser.homedns.org> (permalink)
References <91ff9b33-c212-4be0-8ed0-1f6b16f56865@googlegroups.com>

Show all headers | View raw


Am 08.10.2012 16:07, schrieb iMath:
> To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?

Algorithms are generally language-agnostic, so what is your question

> BTW ,Windows’s calculator get the accurate value ,anyone who knows how to implement it ?

You should use a library that handles arbitrary-precision floating point 
numbers, Python's built-in floating point type corresponds to C's double 
type and that is typically a IEEE float, which means a limited 
precision. Just search the web for one. If you really want to do it 
yourself, you could leverage the fact that Python's integral type has a 
dynamic size, so that it can represent numbers with more than the 
typical 32 or 64 bits width.

BTW: If this is not a homework question, you should ask much more 
specifically. My anwers are intentionally vague in order to not spoil 
you the learning effect.

Cheers!

Uli

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