Monday 06 September 2004 1:21:03 am - 10 replies
Modified on Monday 06 September 2004 6:43:52 am by Mieczyslaw Morzonek
Tobias Persson
Monday 06 September 2004 6:57:27 am
To solve the first I would do something like:
{let var=5.2344} {$var|mul(10)|round()|div(10)} {/let}
use 100 instead of 10 if you want 5.23
Mieczyslaw Morzonek
Monday 06 September 2004 7:41:38 am
Ok, i`ve give up :(
I can`t round result from polls to 00.0 or 00.00 ...
{concat(div(mul($:item_count,100),$total_count))|shorten(4. '')} % this code always show 33.333333333% when 100/3
Monday 06 September 2004 8:54:10 am
I'm abit confused about what you try to do. Do you always want two digits infront of the '.' and one digit behind the '.'
so the transform is something like this?
0 => 00.0 1.5 => 01.512.2 => 12.2
Tuesday 07 September 2004 4:25:35 am
for example:
result of this code {div(mul($:item_count,100),$total_count)} % is 33.333333333 % . I don`t know how to short this 33.333333333 % to 33.33% or 33.3%
Paul Borgermans
Tuesday 07 September 2004 5:53:11 am
If english is your locale, (others may work too), you can use the l10n operator:
{$yournumber|l10n(number)}
In the english locale, it will display numbers with two decimal places
hth
-paul
eZ Publish, eZ Find, Solr expert consulting and training http://twitter.com/paulborgermans
Tuesday 07 September 2004 6:28:10 am
Thank you Paul it works, now i`ve got 33.33% but is possible change this 33.33% to 33.3%?
Finally i need 33.3%
Thanks for your help
Tuesday 07 September 2004 7:00:33 am
Didn't this work? (maybe it doesn't for EZ 3.3-3 ?)
{$var|mul(10)|round()|div(10)}
Tuesday 07 September 2004 7:03:49 am
No, it doesn`t work :(
{div(mul($:item_count,100),$total_count)|l10n(number)} this code shows 33.33% i need 33.3%
your code shows always 1%
Tuesday 07 September 2004 7:17:52 am
We need a template operator for number formatting, which should be easy by implementing the php function sprintf. Any takers?
Christoph von Siebenthal
Monday 01 November 2010 5:47:38 am
Hello Paul
Is that stil on the to do list?
I need it. I take it.
You must be logged in to post messages in this topic!