[Zope] Round This!

Eron Lloyd lloyd@lancaster.lib.pa.us
Wed, 26 Dec 2001 18:32:16 -0500


Hi Ben -

Are you trying to FORMAT this value into a string representation? If this is 
the case, then <dtml-var name="subtotal" fmt="dollars-and-cents"> will do the 
trick. Or, you could turn it into a float first (I assume you get a integer 
for 'subtotal') and then round to two decimal points:
<dtml-var expr="_.round(_.float(subtotal), 2)"> to get a result. You are 
trying to round an integer (because you get an even dollar amount), so 
rounding won't make a difference in decimal amounts. Check the dtml-var API 
documentation for more clarification on the 'fmt' attribute.

Hope that helps,

Eron


On Wednesday 26 December 2001 06:22 pm, Ben Ocean wrote:
> Hi;
> I have a variable, subtotal, that is an even dollar amount. I want to add 2
> zeros to the right of the decimal point. I thought this expression:
> <dtml-var expr="_.round(subtotal,2)">
> would do the trick, but am sadly disappointed. What do I do?
> TIA,
> BenO
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )