Normalization of variables in C ++ between (0,1) to obtain accuracy in arithmetic

I calculated the projections of normalized two-dimensional points and accidentally noticed that they were more accurate than when projecting points without normalizing them. My code is in C ++ and I am compiling with the NDK for an Android mobile phone that lacks FPU (floating point unit).

Why do I get accuracy with C ++ when I first normalize the values ​​so that they are between 0 and 1?

In general, as a rule, in C ++ do you get precision in arithmetic if you work with variables that are between 0 and 1, or is it due to a compilation case for an ARM device?

+6
source share
2 answers

You have a misunderstanding of accuracy. Accuracy is basically the number of bits available to you to represent the mantissa of your number.

You may find that you have more digits after the decimal point if you keep the scale from 0 to 1, but this is not an accuracy that does not change at all based on the scale or sign.

For example, single precision has 23 bits of precision, regardless of whether your number is 0.5 or 1e38. Double precision has 52 bits of accuracy.

See IEEE754 bit level representation for more information.

+9
source

If you perform matrix-based calculations, you can calculate the condition numbers of your matrices. Essentially, a condition number measures the size of the numerical error in your answer, depending on the size of the numerical error at your inputs. They say that the problem with the low condition number is well-conditioned, and the problem with the high state number is called poorly conditioned.

For some problems, you can pre-process your data (for example, scale the units in which you measure certain variables) to make the condition number more favorable. For instance. A financial table in which some columns are measured in dollar cents, while others in billions of dollars are poorly conditioned.

For a detailed explanation, see Wikipedia .

+3
source

Source: https://habr.com/ru/post/916833/


All Articles