I'm not sure what you mean by "string" everything, unless that was a
typo for "strip".  According to the docs, int is supposed to return then
the next smallest integer.  So technically it doesn't even "strip" as
-4.3 would return -5.

If you pass in an even integer, it should come out unscathed.  It
appears in my example; the integer 6 is being stored behind the scenes
as a double and being secretly (and inconsistently) rounded for me.

~Brad

-----Original Message-----
From: Greg Morphis [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 06, 2008 6:02 PM
To: CF-Talk
Subject: Re: CF redefines math: 5 = 6

Doesn't int() just string anything after the decimal away? so
5.99999999 would be 5?
rnd(5.99999) would be 6. ceil(5.9999999999) would also be 6.

On Tue, May 6, 2008 at 5: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:304830
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