DAXSPOT

Tuesday, October 18, 2022

Avoiding "Divided by zero" error, X++

Hi,


Two ways to avoid the error "Divided by Zero".


int    a,b,c;

a = 2;

b = 0;

if(b)

    c = a / b;

else

    print "Cannot divide by zero"

//Output is "Cannot divide by zero" because "b" is zero so else statement will run.


(OR)


c  = a / minOne(b); 

//Output is C = 2, reason given below.


Function minOne() returns non zero values. If "b" is zero then it returns one.


Thank you,


No comments:

Post a Comment

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...