Arrotondamento



Public Enum TipoArrot
arrDifetto
arrMatematico
arrEccesso
End Enum

Public Function Arrot(Valore As Double, _
CifreDopoVirgola As Integer, _
eTipoArr As TipoArrot) As Double

Dim Delta As Double

Select Case eTipoArr
Case arrDifetto
Delta = 0#
Case arrMatematico
Delta = 0.5
Case arrEccesso
Delta = 0.999999999999999
End Select

Arrot = Fix(Valore * (10 ^ CifreDopoVirgola) + Delta) _
/ (10 ^ CifreDopoVirgola)

' uso Fix per arrotondare giusti anche i negativi!


End Function

(arrotondamento.html)- by Paolo Puglisi - Modifica del 25/3/2019