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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

divison by zero 1

Status
Not open for further replies.

Paul1981

IS-IT--Management
Jun 30, 2006
36
0
0
GB
Hi,

I am currently using Crystal Reports XI and have created a report containing a formula which divides two formulas.

The problem is, if the formula's result to '0', then I get the following error message: "Division By Zero".

Is there away of geting around this? I understand you can not divide by '0', but I was wondering if you can ignore?

thanks

Paul
 
I usually handle this with an If statement in the formula (Crystal syntax):

if {@BottomNumber} > 0 then
{@TopNumber} / {@BottomNumber}
else 0

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
You need a slightly different formula to be safe, and it's only the denominator that you need to check for:

if {@BottomNumber} <> 0 then
{@TopNumber} / {@BottomNumber}
else
0

A denominator could be a negative number, so checking for NOT zero is what you should use.

-k

 
Another way would be:

if {@BottomNumber} = 0 then 0
else
{@TopNumber}/{@BottomNumber}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top