pauldy said:

pauldy
web-speechbubble

Sitting around trying to come up with a viable solution for Javascript rounding errors. 2340.66/12 != 195.05499999999998

2 years, 2 months ago.

5 comments so far

  • hkarthik

    I would suggest pulling the calc out of JS and moving into C#. Expose back to the front end using an AJAX call.

    2 years, 2 months ago by hkarthik

  • pauldy

    It's a redesign of an escrow screen that keeps live tallies and totals of 150+ fields on a single screen, I tried ajax but it was just to slow with all the data. So now I'm stuck trying to figure it out in JS.

    2 years, 2 months ago by pauldy

  • hkarthik

    150+ data entry fields on a single screen...the BA who gave you that mock-up needs a severe beat down.

    2 years, 2 months ago by hkarthik

  • pauldy

    What is this BA you speak of? :-p

    2 years, 2 months ago by pauldy

  • pauldy

    The solution to the problem was to figure out how many digits are significant. I went out one decimal point past the last significant digit and add one to it. I can now round to any significant digit without worry of the dreded rounding error. It's an ugly hack but one that will work 100% for my usage.

    2 years, 2 months ago by pauldy

Sign in to add a comment