I tested a bunch of methods and got to the conclusion that these are the fastest, but I'd probably choose the second in the list, I like working with Long instead of Integer:
Code:
n2= n1 - CInt(n1)
n2= n1 - CLng(n1)
n2= CDbl(n1) - CInt(n1)
n2= CDbl(n1) - CLng(n1)
I tried with this string manipulation method as well and it takes about 3 times longer
Code:
If n1 < 0 Then
n2 = ("-0." & Split(FormatNumber(n1, 8), ".")(1)) * 1
Else
n2 = ("0." & Split(FormatNumber(n1, 8), ".")(1)) * 1
End If
It's worth mentioning that I got a slightly faster result with these two, but if there are negatives in the dataset, it's best to not use them
Code:
n2 = n1 - Int(n1)
n2 = n1 - Fix(n1)
Attached is a sample with the 7 methods, but it's clear that string manipulation should not be used. This is the result:
method 1 0.024389
method 2 0.024188
method 3 0.024928
method 4 0.024898
method 5 0.083601 <-- string manipulation
method 6 0.024453
method 7 0.023787