Delphi arendondamento values

I am having the following problem:

                  | Result |
10     / 0,9280 = | 10,77  |
10     / 0,8740 = | 11,44  |
214,35 / 0,9280 = | 230,98 |

Note: This information is written to the server with rounding, equal to the example.

Now if I take this information and invert to show the user the original value:

                   |  Result   |Correto |
10,77   * 0,9280 = | 9,99456   |  10    |
11,44   * 0,8740 = | 9,99856   |  10    |
230,98  * 0,9280 = | 214,34944 | 214,35 |

How can I do this rounding?

Author: Tiago Casanova, 2018-03-22

2 answers

I believe you can use the function System.Math.SetRoundMode . According to the documentation, it can assume rmNearest, rmDown, rmUp or rmTruncate . The documentation brings an example here .

SetRoundMode(rmNearest); // Arredonda para o valor mais próximo
 1
Author: Cleber Griff, 2018-03-23 17:26:20

You are saving the result with only two decimal places, evidently the subsequent multiplication will take into account only the two houses and consequently will not reach the desired value.
As an example, see:

Correct:

10     / 0,9280 = | 10,77586206896552

Your Code

10     / 0,9280 = | 10,77
 0
Author: Andrey, 2018-03-22 14:01:59