We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How can I resolve the exception occurred when division operation is used in ExpressionDescriptor?

Problem:

A decimal does not support unknown division operation, that is, any number divided by zero or zero divided by any number.

Reason:

A decimal number is a floating-point value that consists of a sign, a numeric value where each digit in the value ranges from 0 to 9, and a scaling factor that indicates the position of a floating decimal point that separates the integral and fractional parts of the numeric value.

The decimal number can be used for calculations under following criteria:

  • A Decimal is a 128-bit floating point data type,that should be used where precision is of extreme importance, such as monetary calculations. For more details, please refer this link: what-is-the-difference-between-decimal-float-and-double-in-net
  • One reason that NaN and Infinity values make more sense for floating point arithmetic is that the operations could result in division by zero, not only because the divisor is actually zero, but because it is too small to be represented by the type. For more details, please refer this link: why-is-nan-not-a-number-only-available-for-doubles

Solution:

To perform the division operation in the Expression Field, you can use Double, Integer type. Decimal return type does not support the NaN, Infinity results, because of the above criteria. It can be used only for exact numbers. When you want to perform the division operations while updating the data in the grid, you can use the Double or Integer types.

For example, assume you have a grid with expression columns, Column [A], Column [B] and Column [C]. The Expression column is calculated depending on the values of Column [A] and Column [B]. Exception is thrown when you add the data to the grid for one column, assuming it to be Column [A], it automatically calculates column [B] as zero. Then expression column automatically calculates division operation for Column [A] / 0, that is, column [B], so the result is Infinity.

C#

VB

Sample:

http://www.syncfusion.com/downloads/support/directtrac/general/Expression_Column_Result_Type_As_Double-43158780.zip

Article ID: Published Date: Last Revised Date: Platform: Control:
3444 01/27/2015 11/13/2015 Windows Forms GridGroupingControl
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.