Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Possible Bug in calcuation with Int()

53 views
Skip to first unread message

Meikel

unread,
Aug 8, 2012, 10:10:41 AM8/8/12
to ra...@googlegroups.com
Could someone please look at the following statements and confirm if this is a bug?

<cfset uSeite1 = int((VonSeite-int(VonSeite))*10)> #Numberformat(uSeite1,"999.999")#: Result 0.000 is correct<br>
<cfset uSeite2 = (VonSeite-int(VonSeite))> #Numberformat(uSeite2,"999.999")#: Result 0.100 is correct<br>
<cfset uSeite3 = (VonSeite-int(VonSeite))*10> #Numberformat(uSeite3,"999.999")#: Result 1.000 is correct<br>

<cfset uSeite4=int(uSeite3)>  #Numberformat(uSeite4,"999.999")#: Result 0.000 is false.           -----> Int(1.000) should be 1.000<br>

<cfset uSeite5=int(0.1*10)> #uSeite5#: Result 1.000 is correct<br>


Version Railo 3.3.5.002 final
Betriebssystem Windows 2003 (5.2) 32bit
Remote IP 10.1.2.14
Host Name internetserver
Servlet Container Resin/3.1.9


Thank you

Michael

Geoff Parkhurst

unread,
Aug 8, 2012, 10:50:33 AM8/8/12
to ra...@googlegroups.com
On 8 August 2012 15:10, Meikel <michael.v...@gmail.com> wrote:
>
> Could someone please look at the following statements and confirm if this is a bug?

Just coincidentally, we've discovered this:

#int(-0.1)#

is 0 on Railo (3.3.4.003) and -1 on ACF (9.0.1.something)

Not sure if it's related...

Best,
Geoff

Adam Cameron

unread,
Aug 8, 2012, 4:23:04 PM8/8/12
to ra...@googlegroups.com
Sounds to me like Railo's getting int() and fix() confused.  NB: not tested, but I've come across this before with CF, and that was Adobe's (or possibly Macromedia @ the time) guidance in this case.

--
Adam

Meikel

unread,
Aug 9, 2012, 3:03:54 AM8/9/12
to ra...@googlegroups.com
Hello all,
I created an jira issue: https://issues.jboss.org/browse/RAILO-2021

Many greetings to all Railo-Fans!!!

Michael

Michael Offner

unread,
Aug 9, 2012, 4:11:41 AM8/9/12
to ra...@googlegroups.com
FYI:
Railo simply does a int cast in this case
Java code for it:
public final class Int implements Function {
   public static double call(PageContext pc , double number) {
      return (int)number;
   }
}


but of course we will check in detail

/micha

2012/8/9 Meikel <michael.v...@gmail.com>



--
/micha

Michael Offner CTO Railo Technologies GmbH

Adam Cameron

unread,
Aug 9, 2012, 4:46:13 AM8/9/12
to ra...@googlegroups.com
Yeah, I think - all things being equal - that's the most sensible thing for a function called "int" to do: return the int part of the number (basically lop off everything after the decimal point).

But CFML's not the only language to combine a notion of rounding with that of "integerising", so as illogical as that seems, it's a precedent.  And there's the fix() function to do what int() ought to have been doing in the first place...

--
Adam

Michael Offner

unread,
Aug 9, 2012, 5:39:53 AM8/9/12
to ra...@googlegroups.com
Problem is solved for next Railo 4.0 release.
BUT there is a simple workaround.

Workaround:
you can overwrite the existing int function with your own cfml based one the following way:
copy the code below to a file called int.cfm to lib[/ext]/railo-server/context/library/function.

Code:
<cfscript>
numeric function intt(required numeric n){
return createObject("java","java.lang.Math").floor(n);
}
</cfscript>

/micha




2012/8/9 Adam Cameron <adamcamero...@gmail.com>

Adam Cameron

unread,
Aug 9, 2012, 9:11:24 AM8/9/12
to ra...@googlegroups.com
I'm really impressed with the turn around time on this ticket, mate.  Good work

(just to plug myself, I also said so on my blog: http://bit.ly/MT54hL).

Cheers.

--
Adam
Reply all
Reply to author
Forward
0 new messages