This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: difference in calculation result when using gcc vs Visual studio and optimisation flag


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]