Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding Issue 1

Status
Not open for further replies.

ganjass

Technical User
Dec 30, 2003
154
GB
Hi

CR8
Progress 9.C

I've created a report with one of the fields based on the following formula:

if isnull({@TotalAmnt}) or {@TotalAmnt} = 0 then
0
else
if {#DistinctCount} <> 0 then
(({@TotalCommission} / {@TotalAmnt}) * 100)

else
0

TotalCommision:
{@Total}*({@Commission}/100)

TotalAmnt:
Sum ({@Office}, {@DOE}, &quot;monthly&quot;)+
Sum ({@Littlewoods}, {@DOE}, &quot;monthly&quot;)+
Sum ({@Field Payments}, {@DOE}, &quot;monthly&quot;)


Where some of the results should be 38.9. 39.6, 39.8 etc
although the reults are all being rounded up to 40, even after changing the rounding format to .00, 0r .000 the result is the same, i've tried various rounding formulae such as :

Stringvar x:=totext({your number field}, 3);
Numbervar lg:= Length(x);
x[1 to (lg-1)]

but no joy

cheers in advance
 
I see that you found the old Crystal whitepaper on rounding.

What precision are you getting from your inner formulas?

Work from those outward and you'll find where it's losing precision.

The CD whitepaper is correct, but you may have to do it back upstream.

-k
 
it is not clear to me what you are adding...sorry

what is the name of this formula??

if isnull({@TotalAmnt}) or {@TotalAmnt} = 0 then
0
else
if {#DistinctCount} <> 0 then
(({@TotalCommission} / {@TotalAmnt}) * 100)

else
0


this just seems to be a percentage formula to me...

tracking down rounding errors requires an ANAL approach to rounding..the result of any division or multiplication should be rounded appropriately with the round function.

don't confuse the round() function with the display rounding. Setting the display rounding has absolutely no effect on the calculations.

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top