velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Revusky <jrevu...@terra.es>
Subject Re: comparing monetary value
Date Tue, 15 Oct 2002 10:14:48 GMT
STham@thoughtworks.COM wrote:

>Hi,
>
>   I believed at the moment, all numbers are treated as Integer. Anyone
>came across this problem of manipulating with money value before?
>
>Example :
>
>  Give a certain amount has to be less than a given value.
>
>   if ($someMoneyValue < 0.01) ???
>
>How do people normally handle money in velocity?? Thanks.
>

Apparently, they put some kind of custom "tool" in the context. This 
strikes me as quite undesirable really, though it is a necessary 
workaround due to VTL's lack of support for decimal numbers.

It's not hard to put in a custom tool, but my view is that something as 
basic as decimal arithmetic should just always be there and work in the 
same way. It is undesirable for the ability to do decimal arithmetic to 
sometimes be there and sometimes not and also to work in different ways 
depending on the project you are involved with and what custom tool they 
put in there.

Well, I think it is fair to point out that other template engines, such 
as FreeMarker, the one I am specifically involved with developing, do 
support decimal numbers and decimal arithmetic in the core. In fact, it 
also support locale-specific formatting based on the template's locale. 
So, 1.23 is output as 1,23 in a european locale, for example.

The syntax is a bit different. You would have to write:

<if someMoneyValue < 0.01>
   blah blah
</if>

Anyway, that's information that could be helpful to you.

Best Regards,

Jonathan Revusky
--
FreeMarker-Velocity comparison doc
http://freemarker.sourceforge.net/fmVsVel.html
Velocity->FreeMarker template conversion utility
http://freemarker.sourceforge.net/usCavalry.html




>
>cheers,
>shen
>
>
>
>--
>To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>
>
>
>
>  
>




--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message