Re: [Templates] rounding numbers

[prev] [thread] [next] [Date index for 2005/02/17]

From: Igor Lobanov
Subject: Re: [Templates] rounding numbers
Date: 14:11 on 17 Feb 2005
[% MACRO round(n)
     GET n + 0.5
     FILTER format("%d");
%]
[% round(5) %] # not 6
[% round(1.5) %] # 2
[% round(1.4) %] # 1

On Thu, 17 Feb 2005 15:00:09 +0100, Matthias.Dillier@xxx.xx
<Matthias.Dillier@xxx.xx> wrote:
> templates-admin@xxxxxxxxxxxxxxxx.xxx wrote on 17.02.2005 11:38:44:
> 
> > You can write a couple of simple macros to do it for you:
> >
> > [% MACRO ceiling(n)
> >     GET n + 1
> >      FILTER format("%d");
> >
> >
> >    MACRO floor(n)
> >     GET n
> >      FILTER format("%d");
> > %]
> >
> > [% ceiling(1.5) %]   # round up
> > [% floor(1.5)   %]   # round down
> 
> [% ceiling(2) %]   # gives 3, rounded up to much.
> Or do I misinterpret something here?
> 
> Regards,
> Matthias Dillier
> 
> This message is for information purposes only. It may not be secure or error-free.
> The Swiss National Bank does not accept legal responsibility for any
> consequences resulting from e-mail use.
> 
> 
> _______________________________________________
> templates mailing list
> templates@xxxxxxxxxxxxxxxx.xxx
> http://lists.template-toolkit.org/mailman/listinfo/templates
> 


        -- 
        Best regards,
Lobanov Igor
igor.lobanov@xxxxx.xxx

http://www.template-toolkit.ru - Template Toolkit translations to Russian

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] rounding numbers
Shanta McBain 05:15 on 17 Feb 2005

Re: [Templates] rounding numbers
Andy Wardley 10:38 on 17 Feb 2005

Re: [Templates] rounding numbers
merlyn (Randal L. Schwartz) 13:58 on 17 Feb 2005

Re: [Templates] rounding numbers
Andy Wardley 14:22 on 17 Feb 2005

Re: [Templates] rounding numbers
Matthias.Dillier 14:00 on 17 Feb 2005

Re: [Templates] rounding numbers
Dave Cross 14:10 on 17 Feb 2005

Re: [Templates] rounding numbers
merlyn (Randal L. Schwartz) 17:42 on 17 Feb 2005

Re: [Templates] rounding numbers
Igor Lobanov 14:11 on 17 Feb 2005

Re: [Templates] rounding numbers
Perrin Harkins 14:10 on 17 Feb 2005

Re: [Templates] rounding numbers
Harald Joerg 14:52 on 17 Feb 2005

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52