How is truncation different from loss of precision? They seem like pretty much the same thing to me.
How is truncation different from loss of precision? They seem like pretty much the same thing to me.
Sure, it is loss of precision. But if you think about it, we are losing precision on nearly everything all of the time.
Why are you worried about it?
Truncation means loss of information. Loss of precision is a matter of informational capacity. For example, if you divide two integers, the remainder is lost. That's truncation. When you reserve a bit in an integer variable to store a boolean value (ie: a flag), that's a loss of precision - instead of, say, 256 possible states you have now only 128; each bit sacrificed cuts the range in half...
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Thanks guys. It was a question on a quiz that I missed.
Loss of precision is the result, truncation is one of the possible causes.
Rounding is another possible cause.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"