c++ - Floating point operations resulting in a number that is essentially zero -


i'm doing calculations result in value {-0.707107, 9.61481e-017, 0.707107} when i'm expecting {-0.707107, 0, 0.707107}. second component, while zero, cause problems down road? should it? using c++ doubles.

that depends on intend down road. :-) however, getting results close to, not equal, "mathematical" result should be, 1 must live when using floating point numbers. common solution define "epsilon" value (say, 1e-10) , accept error of epsilon in comparisons - x == y become fabs(x - y) < epsilon.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -