This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL problem

 
ani jadhao
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of mock, I came across one question . I couldnt dig how the answer has been calculated.


<%int num[] ={42,420,4200};
request.setAttribute("foo",num);

%>

${requestScope["foo"][0] ne 10 div 0}

The answer has been evaluated to be TRUE :roll: .Can any one please elaborate how to evaluate such answers?

thanks
Ani
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
requestScope["foo"][0] evaluates to 42.
10 div 0 evaluates to infinity. (don't confuse with modulo than throw exception with 0)
42 != infinity ---> TRUE
 
ani jadhao
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

-requestScope["foo"][0] evaluates to 42.
-42 NE 10 DIV 0
-TRUE DIV 0 :roll:

?? WHAT ABOUT THIS EXPRESSION? hOW COULD THIS BE EVALUATED?
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
according precedence rules (i hope i'm not wrong) div operator is before ne.
this EL is the same as (42 != 10/0) (but EL gives infinity for division by 0)
"TRUE DIV 0" indeed raise an exception, but that's not the case...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
according precedence rules (i hope i'm not wrong) div operator is before ne.

That's right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic