Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: rounding values Post Reply Post New Topic
Author Message
campia
Newbie
Newbie
Avatar

Joined: 14 Mar 2008
Location: Luxembourg
Online Status: Offline
Posts: 1
Quote campia Replybullet Topic: rounding values
     Posted: 14 Mar 2008 at 6:45am
Hi,
 
I use CR XI for my reporting and I have rounding issues on my main and sub report. I need to calculate the total of days users have used under a specific men days contract with a customer.
 
Let's imagine: users have used during January for client A = 24,75 days and on February for the same customer = 5,50 days.In the main report I use a simple cross-tab where i do a sum of the days for a date period (always per month).
 
On the sub report i do a sum of both values (=30,25 days) for both months.
 
However is strange because I have diferences in the values depending the decimals behind the "." ;I show you what I have:
 
29,375 => 29,38
38,656 => 38,66

-------------------
68,031 =>68,03 (that's wrong because if you calculate it, the correct total should be 68,04)
Can you explain me how this is possible?
 
 
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 14 Mar 2008 at 8:31am
To get the correct total, you should do the calculations with the full number of decimal places, and then round it at the very end
 
in your example
29,375 +38,656  = 68,031  which rounds to 68,03 and is correct
 
 
rounding 29,375 => 29,38 has gained you 0,005
rounding 38,656 => 38,66 has gained you 0,004

so adding 29,38 + 38,66 is 0,009 too high and is wrong
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 14 Mar 2008 at 1:44pm
Also, with rounding, 68,031 correctly rounds to 68,03.  For it to round to 68.04, the value would have to be between 68,035 and 68.04.  Numbers greater than 68,03 and less than 68,035 round down to 68,03.  That's the way that rounding works.
 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum