Rounding issue

Hi

I have to migrate an actuate report to crystal, and the results have to be the same.

I am having some issues to get the rounding right. In most cases, it is working but for some numbers I cant get it right. Here is a sample of data I have to round :

Source | Crystal rounding
74.56555929 -> 74.6
72.17861899 -> 72.2
70.02662606 -> 70.0
69.55591111 -> 69.6
68.35693253 -> 68.4
67.59606497 -> 67.6
23.04939053 -> 23.0 -> I should get 23.1
2.44541784 -> 2.4 -> I should get 2.5
0.549062082 -> 0.5 -> I should get 0.6

Is there a way to modify or customize the round function ? Or maybe another function ?

Thanks for the help

Julien


JGasser (BOB member since 2007-11-08)

Posting the solution that was given to me by a friend, just in case someone has the same issue :

Function CustomRounding (myNumber As Double) As Double
    dim result as double
 
    result = round(round(round(myNumber*1000)/CDbl(10))/CDbl(10))/CDbl(10)

    CustomRounding = result
End Function

So with for example 23.0493 as input, it will do

23.0493*1000 = 23049.3
round(23049.3) = 23049
round(23049/10)=2305
round(2305/10)=231
231/10=23.1


JGasser (BOB member since 2007-11-08)