Re: [railo] Order of operations on divs

36 views
Skip to first unread message

Mark Drew

unread,
Feb 13, 2013, 12:10:10 PM2/13/13
to ra...@googlegroups.com
Which one is a bug?

Regards
Mark Drew
Sent from a mobile device

On 13 Feb 2013, at 15:18, Scott Ashman <sas...@jaspin.com> wrote:

Found that the order of operations on divs different in railo when running an ancient app in railo.  Here is a simplified case :

CF9
#765 \ 100 * 100#  = 0

Railo
#765 \ 100 * 100# = 700

There a list of little differences like these?

--
You received this message because you are subscribed to the Google Groups "Railo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to railo+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Peter Boughton

unread,
Feb 13, 2013, 12:12:06 PM2/13/13
to ra...@googlegroups.com

Matthew Williams

unread,
Feb 13, 2013, 12:24:55 PM2/13/13
to ra...@googlegroups.com
Shouldn't your second part of the example be = 765?

From here (http://www.mathgoodies.com/lessons/vol7/order_operations.html), the order is supposed to be:

Rule 1:   First perform any calculations inside parentheses.
Rule 2:   Next perform all multiplications and divisions, working from left to right.
Rule 3:   Lastly, perform all additions and subtractions, working from left to right.



--

Matthew Williams
Geodesic GraFX
www.geodesicgrafx.com/blog
http://twitter.com/ophblance

Peter Boughton

unread,
Feb 13, 2013, 12:30:39 PM2/13/13
to ra...@googlegroups.com
> Shouldn't your second part of the example be = 765?

Nope.

\ = integer division

765 \ 100 = 7

765 / 100 = 7.65

Mark Drew

unread,
Feb 13, 2013, 12:37:14 PM2/13/13
to ra...@googlegroups.com
OK, so if this is a bug with ColdFusion, should we list it in our compatibility page? 

Regards

Mark Drew

The Railo Company
Professional Open Source
skype: mark_railo ma...@getrailo.com
+44 7971 852296 http://www.getrailo.com

Matthew Williams

unread,
Feb 13, 2013, 12:48:17 PM2/13/13
to ra...@googlegroups.com
Ah... interesting.  I've never had cause to do that before.  Well yay for learning something new today then.

James Kilford

unread,
Feb 13, 2013, 1:47:15 PM2/13/13
to ra...@googlegroups.com
Ditto!  Another one of those things that makes wonder... how can I have never known that before?!  

It's never occurred to me that the order of precedence would be the same across languages -- so I put parentheses around every section of a formula, and I think it makes it more readable too. 

James

--

Adam Cameron

unread,
Feb 16, 2013, 3:45:02 AM2/16/13
to ra...@googlegroups.com
Sorry to disagree (*) Peter, but whilst there are accepted precedents for orders of operations, there's no hard and fast rule. And ColdFusion documents that * takes precedence over \: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec09d55-7fff.html

Whether or not it should work like that is debatable, but the docs mirror the implementation, so it's by design.

I think this is one of those situations in which there's no gain in Railo doing it differently from ColdFusion, so this would qualify as a compat bug with CF, and ought to be fixed?

--
Adam

(*) clearly that's a lie ;-)

Justin Carter

unread,
Feb 16, 2013, 6:25:20 PM2/16/13
to ra...@googlegroups.com
Doesn't seem like that docs page is 100% clear, multiply and divide are on the same line separated by a comma so it could be read as having the same importance and therefore should be evaluated from left to right.

But in any case, considering it flies in the face of Maths, it's a bug in CF9. Railo should not "fix" this ;)

Cheers,
Justin

Justin Carter

unread,
Feb 16, 2013, 6:28:17 PM2/16/13
to ra...@googlegroups.com
Oh..... They put integer division on its own line..... Sigh. Still should be fixed, should require parens.

Cheers,
Justin

Geoff Parkhurst

unread,
Jun 4, 2013, 6:58:56 AM6/4/13
to ra...@googlegroups.com
I'm not sure Railo gets integer division correct all the time.

Just been burned by this:

893708281 \ 11 should be 81246207

But railo 4.0.4.001 returns 81246208

int(81246207/11) gives the correct answer though.

Best,
Geoff
Reply all
Reply to author
Forward
0 new messages