Expand my Community achievements bar.

calculations overflow/underflow

Avatar

Former Community Member
Does anyone know what formcalc scripting would be necessary to get rid of the arithmetic overflow/underflow error?



I know that some of my calculations are dependent upon other variables that require value input before anything is set with the others.



I've read a suggestion to 'surround the calculation with a check to ensure that the variables are non-zero, non-null.'



But I'm not sure how to go about this...I'm new at this, so an example would be really helpful! Thanks~
5 Replies

Avatar

Former Community Member
This script would protect against a divide by zero error:



if (someField.rawValue ne 0) then

26 / someField.rawValue

else

0

endif



Chris

Adobe Enterprise Developer Support

Avatar

Level 1

Chris,

If you wanted to place "n/a" in a numeric field if someField.rawValue did equal zero, how would you do that?

Avatar

Former Community Member
thanks, that helps! but i still have a few questions...



I'm assuming this script goes under initialize?



Also, I have calculations within calculations... does this script need to be repeated for each sub-calculation? i.e.:



if 'I_f' is dependent upon 'Ftotal', would I have to insert under initialize:



'if (Ftotal.rawValue ne 0) then

26 / Ftotal.rawValue

else

0

endif



if (I_f.rawValue ne 0) then

26 / I_f.rawValue

else

0

endif'

Avatar

Former Community Member
Actually I assumed you wanted to the script to go under calculate, so I wrote it for that. If the script is going on initialiaze or any other event it would be similar and look like this:



if (someFiel.rawValue ne 0) then

$.rawValue = 26 / someField.rawValue

else

$.rawValue = 0

endif



Anytime there is a possibility that a value from a variable could cause a mathematically error and you don't want to happen you should check the value before running the calculation.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Okay, I've tried both options.

All of the above advice would be very helpful... to the right eyes.

Can anyone recommend a great book that might be able to break it all down for me??