String representations of numbers and approximate equality
Chris Angelico
rosuav at gmail.com
Thu Sep 25 08:46:07 EDT 2014
On Thu, Sep 25, 2014 at 10:40 PM, Dave Angel <davea at 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
More information about the Python-list
mailing list