[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Challenge: find the first value where two functions differ

On Sat, Aug 5, 2017 at 3:51 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> On Sat, 5 Aug 2017 02:31 am, MRAB wrote:
>> Why would isqrt_float not give the correct answer? Probably because of
>> truncation (or rounding up?) of the floating point. I'd expect it to
>> fail first near a square.
> Assuming your math.sqrt() is an IEEE-754 correctly-rounded square root

To clarify: What you're assuming here is that the floating-point value
that math.sqrt returns is exactly the value that you get by rounding
the true square root (even if transcendental) to the available
precision. I *believe* that that's guaranteed for a floating-point
input value, but is it for integer input? Is there any way that (say)
2**53+1 could sqrt to a different value depending on whether you
convert the input to float first?