i get non accuracy result for using simple(* + -) and complex(sin cos pow) math function in std.
someone know very accuracy for math actions?
i get non accuracy result for using simple(* + -) and complex(sin cos pow) math function in std.
someone know very accuracy for math actions?
Can you give us an example piece of code as well as the output you are getting and the output you expect?
Are you using floats instead of doubles? A float can be thought of as a "single" from other languages. A double is more precise than a float.
Every floating-point representation like float, double, or even long double, will inherently have a round-off error. Usually, for these three types it is rounded-off around the 7, 16, and 20 significant digit (although long double may not be different from double, and the precisions can change per platform).
So, even simple operations like +- will not yield exact results (in the sense of continuous real numbers, because it would take infinite space to hold an infinitely precise number). The round-off errors are subject to the same operations as the numbers, so they propagate and accumulate. This is why, for some algorithms, there is significant analysis done to get an estimate of the propagation and accumulation of round-off errors. Techniques to mitigate that problem include: parallel computations where a possibly larger amount of calculation but smaller independent sequences of calculations can reduce the accumulation of error; and interval arithmetic can also be used to replace a value with a lower-bound and upper-bound on its error, this way, at the end, you can get the uncertainty interval of the computed value (this is a bit extreme because it more than doubles the computational load, but it is used sometimes, where, for example, the result uncertainty could make the difference between an airplane designed to crash and one designed to fly!).