G_Thompson
asked on
Rounding Decimals
Fairly important to what I'm doing right now . . . .Is there a function that rounds decimals correctly, as Cint() rounds numbers x.5 to the nearest even number and Int() truncates them.
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In Acc2000 there is a new function Round(<number>,<precision> ), but in online help it is not described. You can find it in object browser.
ASKER
Thank you all for your comments I'm not currently using Acces200 unfortunatly,
I altered one of the functions from a previous answer
Function Round(ToRound As Double) As Double
Dim Multiplier As Double
Dim DecimalP As Integer
DecimalP = 0
If (CInt(ToRound)) Mod 2 = 0 Then ToRound = ToRound + 0.1
Multiplier = 10 ^ DecimalP
Round = CLng(ToRound * Multiplier) / Multiplier
End Function
with out the 0.1 added to even numbers rounding 2.5 gave 2 with the addition of 0.1 it gives 3, correct
because the 0.1 is only added to even no's itdoes not affect other results .
I have just realised i could use
Function Round(value as double)
if cint(value)mod 2 <> 0 then
round = cint(value+0.1)
Else
round = cint(value)
endif
end function
For rounding to 0 dp
Thanks anyway
G Thompson
I altered one of the functions from a previous answer
Function Round(ToRound As Double) As Double
Dim Multiplier As Double
Dim DecimalP As Integer
DecimalP = 0
If (CInt(ToRound)) Mod 2 = 0 Then ToRound = ToRound + 0.1
Multiplier = 10 ^ DecimalP
Round = CLng(ToRound * Multiplier) / Multiplier
End Function
with out the 0.1 added to even numbers rounding 2.5 gave 2 with the addition of 0.1 it gives 3, correct
because the 0.1 is only added to even no's itdoes not affect other results .
I have just realised i could use
Function Round(value as double)
if cint(value)mod 2 <> 0 then
round = cint(value+0.1)
Else
round = cint(value)
endif
end function
For rounding to 0 dp
Thanks anyway
G Thompson