3 Replies Latest reply on Nov 9, 2016 8:32 AM by Dani Szwarc

    Substracting not providing accurate results

    Dani Szwarc Level 1

      Hello people, I have an SQL query that performs some profit calculations before the result is displayed.

      As I was CFlooping, I noticed that while most results (chargeToCustomer - Cost = Profit) were accurate, some of them were off by 1 cent.

      Since I don't know SQL server functions very well, I decided to leave the calculations to Coldfusion.

      But I'm getting similar results. Out of 144 records, I have about 10 that are off by 1 cent.

      Has anyone experienced something similar?

      Is there any decimal function I need to add in order to respect the values? I have the perception that some values are either rounded up or down, which causes the result to be off.

       

      My formula is extremely simple: <cfset myProfit = Charge - Cost>

      No magic, not weird formulas and not hidden fees

       

      Thank you in advance!