C++ function to chop very small numerical values
Is there a C++ function that chops 开发者_开发百科very small numerical values that appear due to approximations of the floating point numbers in the CPU to zero? I want to use this in complex number calculation, so it can appear in either the real or imaginary parts.
No such function exists. The problem is that "small" is relative. If you're working on very large numbers, 1.0
can be considered small enough to chop. Similarly, if you're working with small numbers, 10^-30
could still be considered significant.
精彩评论