This is a relic of CF's refusal to understand integers.  All numerics
within CF are treated as floating point numbers (java.lang.Double).
As such, integer arithmetic doesn't exist.  Most of the time it's no
big deal, and CF does some autocorrection when doing certain
operations, but it can occasionally bite you.

cheers,
barneyb

On Tue, May 6, 2008 at 3:40 PM, Brad Wood <[EMAIL PROTECTED]> wrote:
> My coworker ran into this today.  We were able to reproduce it on CF 6,
>  7, and 8.
>  The variable x is equal to 6.  When passed into the int function you get
>  5 back.  This must be some sort of precision thing with internal
>  rounding.
>
>  <cfset x = (2280.66 + 0.00) / 380.11>
>
>  <!--- output results --->
>
>  <cfoutput>
>  (2280.66 + 0.00) / 380.11=#(2280.66 + 0.00) / 380.11#
>
>  <hr>
>  x=#x#
>
>  <BR>
>  val(x)=#val(x)#
>
>  <BR>
>  int(x)=#int(x)#
>
>  </cfoutput>
>
>  ==================================
>
>  In related news,
>
>  int(5.999999999999999) = 5
>  but,
>  int(5.9999999999999999) = 6
>
>  Explanations?
>
>  I found this and it seemed to help:
>  http://en.wikipedia.org/wiki/Computer_numbering_formats#Representing_fra
>  ctions_in_binary
>
>  ~Brad
>
>  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304821
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to