Skip to main content
April 9, 2025
Question

Decimal Calculation

  • April 9, 2025
  • 9 replies
  • 0 views

Hello Everyone,

We allow users to enter the amounts in the editable grid using the textbox component. (saving these values in the CDT decimal field)

And displaying the total amount and validating the total column against other values.

Values entered are :

430603.10
13871.55
117011.65
23402.33

Would like to know why the sum function is not giving the value with the correct precision.  

And also to calculate the sum with correct precision, do we need to use Fixed?

    9 replies

    stefanhelzle0001
    April 9, 2025

    Computers represent decimal number with a limited precision. In your case, trying to convert between text and decimal multiple times does not help either.

    Fixed should only be used to display a value to the user as it returns a string.

    mathieud0001
    April 9, 2025
    April 10, 2025

    Since it is a textbox field, the user can enter multiple digits after the decimal, and I need to save the number with precision 2.

    To save the values in the local variable/cdt decimal field fixed(<<input value>>, 2) is the correct choice? 

    mathieud0001
    April 10, 2025