VBA.VB6 - Avrundingsfunksjon (større eller mindre enn n sifre)

Funksjonen Round () gir feil avrunding av tallene i følgende skjema:

(2a + 0, 5) x 10 ^ -n (runde halv ned)

Ved ulemper er tallene på skjemaet (2a - 0, 5) x 10 ^ -n vanligvis Runde halv opp.

Forfatter: Patrice33740

For eksempel:

Runde (0, 15, 1) = 0, 2

Runde (0, 25, 1) = 0, 2

Rund (0, 35, 1) = 0, 4

Runde (0, 45, 1) = 0, 4

Avrundingsfunksjonen gitt nedenfor har ikke denne anomali:

Runde (0, 15, 1) = 0, 2

Runde (0, 25, 1) = 0, 3

Rund (0, 35, 1) = 0, 4

Rund (0, 45, 1) = 0, 5

 Private Funksjon Runde (ByVal Antall, ByVal Decimal) Arrondi = Int (Antall * 10 ^ Desimal + 1/2) / 10 ^ Desimal End Funksjon 

Forrige Artikkel Neste Artikkel

Beste Tips