Expand my Community achievements bar.

SOLVED

Division aritmetic overflow

Avatar

Level 2

Need Help please.

I have to numeric fields that I need to make a division and have a result in the 3rd one.

If I only use numericfield1 / numericfield2   I have this error. I search and I see somthing about zero I try many diferent ways and I can not make a simple division.

Thank You in advance for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 7

It is because you can't divide by zero which is what would be happening if one of the fields was empty so perhaps the calculation of the third box should be (in formcalc):

if (NumericField1.isNull == 0 and NumericField2.isNull == 0) then

    $ = NumericField1/NumericField2

else $ = ""

endif

this is saying that it should only do the calculation if both the other fields have a value in them

View solution in original post

6 Replies

Avatar

Correct answer by
Level 7

It is because you can't divide by zero which is what would be happening if one of the fields was empty so perhaps the calculation of the third box should be (in formcalc):

if (NumericField1.isNull == 0 and NumericField2.isNull == 0) then

    $ = NumericField1/NumericField2

else $ = ""

endif

this is saying that it should only do the calculation if both the other fields have a value in them

Avatar

Level 2

This work fine but now I have an overflow in a different situation.

The question is: NumericField1 is a result of a sum and NumericField2 is also a result of a sum  and the 3rd field needs the result of a division of both fields. I use the if/then statement but have an overflow error.

I don't know if I can use something like this

if (NumericField1.IsNull = 0 and NumericField2 = >0) then

    $ = NumericField1/NumericField2

else $ = ""

endif

I realy do not know how to do it. Thank You

Avatar

Level 10

You sytax is wrong:

The comparision needs the operator === (JavaScript) or eq (FormCalc) or >= (JavaScript) or ge (FormCalc).

Also, you wrote the function isNull with a uppercase character, which causes you calculation to fail, cause there is no function IsNull, only isNull.

Avatar

Level 2

Thanks but is not working.

Let me try to explain.

I have a numericField (1) that is the sum (total) of other numeric fields and I have a second numericfield(2) that is binding from other field call pounds (Just copy the total pounds) What I need is to divide NumericField 1 / NumericField2.

I did what you say but still not get the division.

Thank You.

Avatar

Level 2

Well what I did and work was this:

if (NumericField1.isNull == 0 and NumericField2.rawValue) then  

$ = NumericField1/ NumericField2

else $ = ""

endif

I don't know if the syntax is OK but work fine.

Thanks every one.