Delphi arendation values

0

I have the following problem:

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

Note: This information is stored on the server with rounding, just like the example.

Now if I take this information and flip it 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?

    
asked by anonymous 22.03.2018 / 14:53

2 answers

0

You are saving the result with only two decimal places, evidently the subsequent multiplication will only take into account 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
    
22.03.2018 / 15:01
0

I believe you can use the System.Math.SetRoundMode function. 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
    
23.03.2018 / 18:26