Solved

NumberVar Rounding/Integer Problem

Posted on 2010-11-23
10
1,820 Views
Last Modified: 2012-05-10
We have an issue with a report that is returning the incorrect value.

We use the following formulas:

CALCVAR (Report Header1)
Whileprintingrecords;
Numbervar justabove;
justabove:= 0.1;

CALCANALYSIS (Report Header2)
Whileprintingrecords;
Numbervar justabove;
Stringvar analysis;
If {field1} – {field2} >= just above then analysis:= “just below average”
Note: (The mathematical calculation of the two fields is 0.1)  

DISPLAYANALYSIS (Report Footer 1)
Whileprintingrecords;
Stringvar analysis;

When DISPLAYANALYSIS is used in the report it returns nothing.  
Is this something to do with rounding? Or using numbvar to store 0.1 as it works with other numbers such as 1.5 (if I change justabove:= 0.1 to justabove:= 0.5 and update the database fields to match)

Please help, I am sure I must be doing something daft.
0
Comment
Question by:optimumreports
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 200 total points
ID: 34196047
It's not obvious to me that it's a precision problem although i won't rule it out because accuracy of decimals is always a potential issue.


Perhaps it would be worth testing a variation of this. Set justabove to 1 and do..

If int({field1}*10) – int({field2}*10) >= justabove then analysis:= “just below average”
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 150 total points
ID: 34197202
I suspect it is a rounding issue.  remember computers use base 2 or binary.  This limits the values that can be displayed/saved as exact values.

0.1 cannot be saved exactly so I think you are getting a round problem

One way to check would be as peter suggests.

mlmcc
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 150 total points
ID: 34203400
FWIW, I did a couple of quick tests and your formulas seem to work fine here.  i wouldn't really expect precision to be a problem, unless your values are unusually large, or have a lot of decimal places.

 I'd try changing the last line in the second formula to just

{field1} - {field2}

 and see what you get.

 James
0
 
LVL 1

Author Comment

by:optimumreports
ID: 34204465
Thanks guys...

We'll test this this afternoon and feedback to you all.

Cheers,

Tom
0
 
LVL 1

Author Comment

by:optimumreports
ID: 34231190
Many thanks for the suggestions sorry for my slow delay in getting back to you.

I have tried the following as suggested but it still returns blank data:

1

whileprintingrecords;
Numbervar justabove;

justabove:= 1; // Set from 0.1 to 1 as suggested

2

whileprintingrecords;
numbervar justabove;

stringvar holding_Writing;

if {KS1_All.Writing Significant} = true and {KS1_All.Writing APS} > {National_All.Writing APS} then holding_Writing:= "significantly above"
else if {KS1_All.Writing Significant} = true and {KS1_All.Writing APS} < {National_All.Writing APS} then holding_Writing:= "significantly below"
else

(
if  int({KS1_All.Writing APS}*10) - int({National_All.Writing APS}*10)  >= justabove then holding_Writing:= "just above"
);

Any ideas?

Tom
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 100

Expert Comment

by:mlmcc
ID: 34231706
Does the report show the values of the fields being used?
If not can you put them on the report and show us what you are getting

mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 34236617
Or, as I suggested before, just change the last line in your second formula to {field1} - {field2}.  The point of that is to see the actual value that CR is getting from that calculation.  Of course the assumption there is that the result of that formula is visible on the report (not in a suppressed field or section).  And you may need/want to change the field format to show more decimal places, to get a more precise view of the value.

 James
0
 
LVL 1

Author Comment

by:optimumreports
ID: 34248822
Hi all,

When we use the following integer formula it returns the data correctly which is great:

if  int({KS1_All.Writing APS}*10) - int({National_All.Writing APS}*10)  >= justabove then holding_Writing:= "just above"

However, now the integer formula is working when mutiplying by 10, I would just like to to confirm if the precision problem identified would affect any of the following variables or is it just where it is 0.1 and -0.1?

verysigabove:=3
sigabove:=2
wellabove:=1
above:=0.5
justabove:=1 \\previuously 0.1
verysigbelow:=-3
sigbelow:=-2
wellbelow:=-1
below:=-0.5
justbelow:=-1 \\previuously -0.1
inline:=0

Or will I need to mutiply all instances by 10?

Cheers,

Tom
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34249150
Since integers can be represent exactly it shouldn't affect any of them.  Even .5 is represented exactly so that should be ok

mlmcc
0
 
LVL 1

Author Closing Comment

by:optimumreports
ID: 34284013
Thanks for the feedback. Sorry we didnt get straight back to you all - we are really busy here at the moment.

Thanks again for your help - much appreciated.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now