Skip Menu |

This queue is for tickets about the HTML-Template-Pro CPAN distribution.

Report information
The Basics
Id: 19739
Status: resolved
Priority: 0/
Queue: HTML-Template-Pro

People
Owner: vlasenko [...] imath.kiev.ua
Requestors: yorhel [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: (EXPR) Integer divisions don't return floats
When you perform calculations in EXPR on integers, only integers are returned (outputted), but divisions for example don't always return integers. For example: <TMPL_VAR EXPR="1/3"> == 0 <TMPL_VAR EXPR="1.0/3.0"> == 0.333333 <TMPL_VAR EXPR="2/3"> == 0 <TMPL_VAR EXPR="2.0/3.0"> == 0.666667 This can become quite annoying when using variables: <TMPL_VAR EXPR="sprintf('%.2f', (part/total*100))"> % The 2 digits after the decimal point will be zero when either the variable 'firstpart' or 'total' is an integer. The following ugly hack will give the expected result: <TMPL_VAR EXPR="sprintf('%.2f', (sprintf('%f', part)/sprintf('%f', total)*100.0)"> % I'm using perl 5.8.7 i686-linux-thread-multi and HTML::Template::Pro 0.64
fixed in 0.65