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, and that int() correctly truncates, the only source of errors is that not all integers are representable as floats. No integer larger than or equal to 2**1024 can be represented as a float. No *odd* integer larger than 2**53 can be represented as a float. Between 2**53 and 2**54, float can only represent multiples of 2. Between 2**54 and 2**55, float can only represent multiples of 4. Between 2**55 and 2**56, float can only represent multiples of 8. And so on. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list