Skip to main content
Participant
May 12, 2010
Question

Expression calculates to very small number instead of zero

  • May 12, 2010
  • 1 reply
  • 276 views

Here's a simple calculation:

<cfset ans = 50.4 - (336 - 285.6)>
<cfoutput>#ans#</cfoutput>

It's zero, right? Run this in CF9 and you get 2.13162820728E-014. I patched my code to ignore values less than 0.01, but this looks like a bug. Has anyone else experienced this issue?

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 12, 2010

    Yep.  Anyone who has ever done floating point math on a computer...

    http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems

    --

    Adam