velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Lynch" <>
Subject Status of floating point literals and arithmetic?
Date Tue, 08 Aug 2006 17:39:55 GMT
I just ran into a case where I wanted to do something like the following in
a template:

#set($fontSize1Percent = 85)
#set($fontSize2Percent = 0.75 * $fontSize1Percent)

When this didn't parse, I searched the velocity mail archives for
information on floating points, and found the the lengthy 2002 discussion.
The impression I got was that there was some interest in adding the ability
to specify floating point literals and to allow floating point arithmetic.
Was anything actually checked in for it?  (As I recall the 1.4 release came
out quite a while after 2002.)  If not, is the current best practice for
this sort of thing to use the MathTool class in the GenericTools
sub-project?  With that, I could do something like:

#set($fontSize1Percent = 85)
#set($reduction = $math.div(75, 100))
#set($fontSize2Percent = $math.mul($reduction, $fontSize1Percent))

       --Paul Lynch

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message