Hi JohnE,

> Basically I am getting a decimal when I should be getting an int with the 
> following code I use in production already:
> 
> #set ($colSize = ($jpPop.size() / 3) - 1)
> THE COLUMN SIZE IS $colSize
> 
> when colSize is printed out it gives a number like 6.3333333 when all values 
> in this calculation are integer.   I should get 6 as an int according to the 
> documentation.

The User Guide says:
"When a division operation is performed between two integers, the
result will be an integer."
    http://jakarta.apache.org/velocity/user-guide.html#Math

The MathUtils#divide javadoc says:
"Integer-types will be returned as Integer-type if and only if the
modulo of the two numbers is 0."
    
http://svn.apache.org/repos/asf/jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java

They can't both be right.  If you consider backward compatibility, the
user guide should be correct.  But my mind says the javadoc is more
convenient...  Will?
cf. http://issues.apache.org/bugzilla/show_bug.cgi?id=25874
    
http://mail-archives.eu.apache.org/mod_mbox/jakarta-velocity-dev/200501.mbox/[EMAIL
 PROTECTED]

> From what I can see there is no way to make a float an integer either.  This 
> too I would imagine could be a problem.

For now, you can use the MathTool.
    http://jakarta.apache.org/velocity/tools/generic/MathTool.html#toInteger()

> I was hoping to push this into production tonight but it will have to wait 
> till I can figure out what to do with the potential affects this could have 
> to the whole system or...it gets resolved.

Which, I guess, makes a good reason for the user guide to be right.

Best regards,
-- Shinobu

--
Shinobu Kawai <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to