Skip to main content
Participant
August 17, 2009
Answered

ColdFusion bug

  • August 17, 2009
  • 1 reply
  • 805 views

Hi,

i got this situation: there are 3 parameters whose total = 0 but the result is not 0! Can you please try on your server to see if you have the same result. If yes please help to fix or to post this to Adobe!

<cfset  a= 2183.41>
<cfset b=3291.15>
<cfset c=1107.74>

a - b + c should be 0 but it is equals -2.27373675443E-013

thank you very much!

Don

    This topic has been closed for replies.
    Correct answer Prasanth_Kumar_S

    This is because the internal representation of the values are not adding to 0. You can fix this temporarily by trimming those values.

    #numberformat(a-b,0000.00)+c#

    This will remove the trailing digits except 2. Now your result will be correct.

    N.B: you can see the actual result of first subtraction by running the below code snippet

    numberformat(a-b,.000000000000000000000). you can notice the value is not exactly zero.

    -Prasanth

    1 reply

    Prasanth_Kumar_S
    Prasanth_Kumar_SCorrect answer
    Inspiring
    August 17, 2009

    This is because the internal representation of the values are not adding to 0. You can fix this temporarily by trimming those values.

    #numberformat(a-b,0000.00)+c#

    This will remove the trailing digits except 2. Now your result will be correct.

    N.B: you can see the actual result of first subtraction by running the below code snippet

    numberformat(a-b,.000000000000000000000). you can notice the value is not exactly zero.

    -Prasanth

    don2009Author
    Participant
    August 18, 2009

    Hi Prasanth,

    it works fine now.

    thank you very much!

    Doan