[Zope] dtml decimals
Tres Seaver
tseaver@digicool.com
Thu, 14 Dec 2000 08:18:21 -0500
Andy McKay <andym@ActiveState.com> wrote:
>
> <dtml-var "3/2" fmt="%.2d"> instead of getting 1.50 as I was expecting I get
> 1.00, I never seem to be getting decimals. Whats the obivous thing Im
> missing here?
Note the following::
$ python
Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 1...
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 3/2
1
>>> 3.0/2
1.5
Python performs integer division when handed integer arguments;
you need::
<dtml-var "3.0/2" fmt="%.2d">
<dtml-var "_.float( x )/2" fmt="%.2d">
or equivalent.
Tres.
--
===============================================================
Tres Seaver tseaver@digicool.com
Digital Creations "Zope Dealers" http://www.zope.org