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


Groups > comp.lang.python > #78339 > unrolled thread

Re: String representations of numbers and approximate equality

Started byChris Angelico <rosuav@gmail.com>
First post2014-09-25 22:46 +1000
Last post2014-09-25 22:46 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: String representations of numbers and approximate equality Chris Angelico <rosuav@gmail.com> - 2014-09-25 22:46 +1000

#78339 — Re: String representations of numbers and approximate equality

FromChris Angelico <rosuav@gmail.com>
Date2014-09-25 22:46 +1000
SubjectRe: String representations of numbers and approximate equality
Message-ID<mailman.14357.1411649176.18130.python-list@python.org>
On Thu, Sep 25, 2014 at 10:40 PM, Dave Angel <davea@davea.name> wrote:
> Another approach is to see if twiddling the last digit gets you
>  from too high to too low. I used this approach to check a trig
>  package I wrote in '75. An answer was close enough if twiddling
>  the last digit changed the result value from too high to too low,
>  or if twiddling the last digit of the argument did. I needed to
>  go both ways because the curve sometimes had a slope greater than
>  one.

Ooh, that sounds clean. So, something like this:

if x * FACTOR > y:
    reduce_last_digit_of_x
    if x * FACTOR > y: error
otherwise do the opposite check

? That's pretty doable.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web