Hi all

I have a scenario where I need to truncate a number to 4 decimal places ( no rounding) .

I have searched google and this site and found the Get() Function. This function works great IF the decimals to 4 places are greater 0 ( 515.1234678 gives me 515.1234) however if the number is to only 1, 2 or 3 decimal places places it does not work ( 515.40000000 gives me 515.3999 - my expectation would be 515.40000000 = 515.4000)

Here are the two Functions i have used to try get this resolved

Am I using these correctly or is there another fix that could be used ?

Thank you in advance

I have a scenario where I need to truncate a number to 4 decimal places ( no rounding) .

I have searched google and this site and found the Get() Function. This function works great IF the decimals to 4 places are greater 0 ( 515.1234678 gives me 515.1234) however if the number is to only 1, 2 or 3 decimal places places it does not work ( 515.40000000 gives me 515.3999 - my expectation would be 515.40000000 = 515.4000)

Here are the two Functions i have used to try get this resolved

Code:

```
Function FixFuntion(number As Double) As Double
FixFuntion = Fix(number * 10000) / 10000
End Function
Function FixDecimal(ByVal number As Double, ByVal digits As Integer) As Double
Dim x As Integer
x = 10 ^ digits
FixDecimal = Fix(number * x) / x
End Function
```

Thank you in advance

Last edited by a moderator: