VBA.VB6 - Funzione arrotondamento (maggiore o minore di n cifre)

La funzione Round () fornisce arrotondamenti errati i numeri nel seguente formato:

(2a + 0, 5) x 10 ^ -n (semirotondo)

Con contro, i numeri del modulo (2a - 0, 5) x 10 ^ -n sono solitamente arrotondati a metà.

Autore: Patrice33740

Per esempio:

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

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

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

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

La funzione di arrotondamento indicata di seguito non presenta questa anomalia:

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

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

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

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

 Funzione privata Round (ByVal Number, ByVal Decimal) Arrondi = Int (Number * 10 ^ Decimal + 1/2) / 10 ^ Decimal End Function 

Articolo Precedente Articolo Successivo

I Migliori Consigli