All,
I seem to recall that in one of the (semi)recent releases, Velocity
started supporting floatingpoint values for mathematical operators (+,
, *, /) as well as comparisons (<, >, <=, >=, ==), but I can't find
anything in the documentation that suggests that this is the case.
A simple test run against Velocity 1.7 works as I expect:
Here is some math:
#set($fourAndAHalf = 4.5)
$fourAndAHalf ($fourAndAHalf.class.name)
#set($halfThat = $fourAndAHalf / 2)
$halfThat ($halfThat.class.name)
#if($fourAndAHalf > $halfThat)
works
#else
confused
#end
That is, the output of this script is:
"
Here is some math:
4.5 (java.lang.Double)
2.25 (java.lang.Double)
works
"
So, it appears that floatingpoint math is supported. When attempting to
run the same template under Velocity 1.4, I get this exception:
Exception in thread "main"
org.apache.velocity.exception.ParseErrorException: Lexical error:
org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line
2, column 24. Encountered: "5" (53), after : "."
at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:286)
at VelocityDriver.main(VelocityDriver.java:70)
It seems clear that Velocity 1.4 does not support floatingpoint math
but that Velocity 1.7 does. Is it documented anywhere that 1.7 (or 1.6?)
supports floatingpoint math directly in the templates?
I have an old project that uses VelocityTools' MathTool to do all kinds
of stuff and I'd like to remove all that for clarity, but I need to be
reasonably confident that I can do that  at least to a certain degree
(e.g. simple math works, but certain operators don't support floats).
Thanks,
chris
