On 26/04/2018 07:24, Игорь Сотниченко wrote: > Thanks for the answer, a problem with floating point. > I want to understand why disabling optimization solves the problem? http://c-faq.com/fp/ See question 14.4a Floating point numbers are approximations of real numbers. For example, adding a "large" number to a "tiny" number "loses" the precision of the tiny number. Addition is not associative. Compilers are allowed to perform the computation in higher precision than the actual type, which may affect the result. If you have a lot of time on your hands, and a desire to learn, you may also want to read: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html Regards.