Skip to main content

Posts

Showing posts with the label Error division by zero

Error division by Zero

  AX / D365FO – How to prevent the error ‘Division by zero’ If you’re gonna write code like A = B /C, you better make sure that C holds a value. Of course you can do a check with a simple if-statement (if C then A = B/C), but there is an easier way. You can use  minOne , a method that exists in the Global class. int a,b,c; if(b) c = a / b; else print " Cannot divide by zero" OR c = a / c = a / minOne(b) ; //it returns a itself if b is zero because minOne() returns non zero values that we passes. I //it returns a itself if b is zero because minOne() returns non zero values that we passes. I f it is zero then it retuns 1