Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

${25/5} output 5.0 why not 5?

 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${25*5} gives output of 125 as expected.
But ${25/5} gives output of 5.0 , why not 5?

Regards,
Joshua
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the following rules are applied for the division :

� IfAorBisaBigDecimal or a BigInteger, coerce both to BigDecimal and return
A.divide( B, BigDecimal.ROUND_HALF_UP ).
� Otherwise, coerce both A and B to Double and apply operator


For the multiplication, both values will be coerced to Long.
So you'll get something similar to :

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic