This is a Round Function to the second digit that I made.
When I send 0.054
I want that it returns 0.05
and when I send 0.055
I want that it returns 0.06
I tought it was working fine but now I saw that:
I send 30.24 to this and it return me 30.23
Here is my function:
Public Function RoundAll(ByVal chiffre As Decimal) As Decimal
Dim digit As Integer
digit = (chiffre * 1000) Mod 10 - (((chiffre * 1000) Mod 10) Mod 1)
Dim temp As Decimal
temp = (chiffre / 0.001) Mod 1000000000000 - (((chiffre / 0.001) Mod 1000000000000) Mod 1)
temp = (temp / 10) - ((temp / 10) Mod 1)
temp = temp / 100
If digit >= 5 Then
chiffre = temp + 0.01
Else
chiffre = temp
End If
Return chiffre
To this line "temp = (chiffre / 0.001) Mod 1000000000000 - (((chiffre / 0.001) Mod 1000000000000) Mod 1)", I check what temp variable contain and it's 30239, I don't understand...
Can somebody help me?
When I send 0.054
I want that it returns 0.05
and when I send 0.055
I want that it returns 0.06
I tought it was working fine but now I saw that:
I send 30.24 to this and it return me 30.23
Here is my function:
Public Function RoundAll(ByVal chiffre As Decimal) As Decimal
Dim digit As Integer
digit = (chiffre * 1000) Mod 10 - (((chiffre * 1000) Mod 10) Mod 1)
Dim temp As Decimal
temp = (chiffre / 0.001) Mod 1000000000000 - (((chiffre / 0.001) Mod 1000000000000) Mod 1)
temp = (temp / 10) - ((temp / 10) Mod 1)
temp = temp / 100
If digit >= 5 Then
chiffre = temp + 0.01
Else
chiffre = temp
End If
Return chiffre
To this line "temp = (chiffre / 0.001) Mod 1000000000000 - (((chiffre / 0.001) Mod 1000000000000) Mod 1)", I check what temp variable contain and it's 30239, I don't understand...
Can somebody help me?