1.#QNAN000000000000 interrupts the loop : This is my problem: I am simulating a particle random walking ((my full codes are long)) in a spherical region (of radius 0.5, with a reflective boundary outside) with absorbing boundary at radius r = 0.05. It starts at r = 0.25 and the loop will stop when it hits the absorbing boundary. However, the loops are always interrupted by value 1.#QNAN000000000000. For example, I am writting the distance to the origin in a file:


... ... (a lot of numbers omitted)

0.20613005432153597

0.20623630547871444

0.20638287597603161

0.20639479244526721

0.20632936118972162

0.20624097359751253

0.20634346836172857

0.20662686334789271

0.20662651327072232

0.20661986008216310

0.20662358691463298

0.20661462509258177

0.20649145569824909

0.20651885241720047

0.20652145059961324

0.20651490447436160

0.20646925001041655

0.20645889385120675

0.20629285654651422

0.20633769635178317

0.20635757642249095

0.20645451482187596

0.20654217470043859

1.#QNAN000000000000

Here the problem arises, the particle is not yet absorbed, but 1.#QNAN000000000000 interrupts the loop. I vaguely know that this might be due to issues in arithmetric operations of floats, but I am paying considerable attention to this. Therefore, I am wondering what I should probably do to avoid these kind of things? Thanks a lot! 