Well, all that conversion between double and string isn’t going to help with the runtime. Converting from double to string to double doesn’t seem very efficient. Can you remove any of them?
But probably the real problem is that you need a better algorithm, something more deterministic that the loop and test.
I think the reason people may be suggesting reading the input as strings is because of the precision error when storing many floating-point numbers. You can avoid the error entirely if you don’t use any floating-point numbers.