Summary Row incorrect value on SUM

4 posts, 0 answers
  1. Shaun
    Shaun avatar
    39 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2013 Link to this post

    Hi,

    I have a gridView with a bunch of columns and a bottom summary row which also has a bunch of SUM columns.
    One of my columns, "volume" has 2 decimal places but the summary row seems to be rounding the values therefore gives an incorrect value.

    I have formatted the summary to show 2 decimal places, which is does but the SUM calculation is still incorrect.

    To test this I added an export to excel function so that I could use Excel to double check the total SUM of the Volume column and this does show that the Grid summary is incorrect.

    I know I must be missing something obvious but I cannot see it.

    Thanks for your help.

    Cheers
    Shaun.

  2. Shaun
    Shaun avatar
    39 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2013 Link to this post

    Hi,

    I managed to fix this by changing "Volume" to a double from a float within my class.

    The grid now calculates correctly, but I still find it a bit odd that all the values within the grid displayed OK but the SUM value is / was incorrect.

    Cheers

    Shaun
  3. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 30 Sep 2013 Link to this post

    Hi Shaun,

    Thank you for contacting Telerik support.

    Sometimes abnormalities can be observed when using floating-point numbers. For example you can take a look at the following discussions:c# - Floating point operations ambiguity or Why is floating point arithmetic in C# imprecise? 

    What I can recommend you, especially if you have financial calculations in you project is to use the decimal floating-point real number type in C#.  Some of the advantages of this type are:
    • No round-off errors
    • Almost no loss of precision

    Please let me know if there is something else I can help you with.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  4. Shaun
    Shaun avatar
    39 posts
    Member since:
    Sep 2012

    Posted 03 Oct 2013 Link to this post

    Hi Dimitar,

    Thanks for getting back to me, I'll check out your links.

    Cheers

    Shaun.
Back to Top