8 Replies Latest reply on Nov 8, 2017 1:23 AM by Axell

# Crystal Reports 2013 - Division by zero.

I'm unable to divide two decimal attribute in Crystal Reports 2013, it always give me "Division by zero."

Field 1 value is 1,960.00

Field 2 value is 20.00

But when I set the formula to {Field 1} / {Field 2}, I will received "Division by zero." error. Anyone can assist me?

• ###### 1. Re: Crystal Reports 2013 - Division by zero.

A simple solution would be.

= IF {Field 2} = 0 THEN 0 ELSE  {Field 1} / {Field 2}

Julian

MarXtar Ltd

• ###### 2. Re: Crystal Reports 2013 - Division by zero.

Hi Julian,

I tried it before, below is the formula:

IF {Field 2} = 0

THEN 0

ELSE {Field 1} / {Field 2}

But the result is still 1,920 instead of 98 (1,920 / 20).

When my formula is {Field 1} only, the result is 1,920.00.

When my formula is {Field 2} only, the result is 20.00.

• ###### 3. Re: Crystal Reports 2013 - Division by zero.

Does it work if they are integer values;  ie is it a problem with being decimals?

Just as a test,  does  INT({Field1})/INT({Field2}) work, as perhaps if so that'll point to decimal division not being liked.

I saw something on the internet about needing to set a "Fixed Point Arithmetic" checkbox but I couldn't find that anywhere in my Crystal Designer 2013 setup so maybe a red-herring!

Julian

MarXtar Ltd

• ###### 4. Re: Crystal Reports 2013 - Division by zero.

I tried INT ({Field1}) / INT ({Field2}) and INT ({Field1}) \ INT ({Field2}) but no luck.

• ###### 5. Re: Crystal Reports 2013 - Division by zero.

{Field1}) + {Field2} and {Field1} - {Field2}  is working fine.

• ###### 6. Re: Crystal Reports 2013 - Division by zero.

Weird one for sure!

• ###### 7. Re: Crystal Reports 2013 - Division by zero.

Incidentally, I also wondered if it coul be something to do with culture/language setting on the report misinterpreting the comma as not being a thousand seperator; that is until you said addition and subtraction work OK.

Julian

MarXtar Ltd

• ###### 8. Re: Crystal Reports 2013 - Division by zero.

Yeah, weird.

I found workaround for this issue which I divide the value in SQL and use addition summary in Crystal Report.

Thanks JulianWigman, really appreciate for your prompt response.