List Info

Thread: string_format rounding error..




string_format rounding error..
user name
2007-01-23 05:31:49
Smarty Version: 2.6.0 (on debian stable) There is a rounding problme with .xx5 on smarty's string_format:"%.2f" modifier. This some times get correct, other times not. I can't seem to find why this is, but here is code that should reproduce said problem: {% assign var="vat" value="0.525" %} {% assign var="total" value="10.95" %} {% math equation="x+y" x=$total y=$vat assign="total_total" %} {% $vat %}
{% $vat|string_format:"%.2f" %}
{% $total %}
{% $total|string_format:"%.2f" %}
{% $total_total %}
{% $total_total|string_format:"%.2f" %}
Expected output 0.525 0.53 10.95 10.95 11.475 11.48 Actual output 0.525 0.53 10.95 10.95 11.475 11.47 -- Jonathan Lozinski Senior Developer SBsquared Limited The Old Forge Hoults Estate Walker Road Newcastle upon Tyne NE6 1AB T: +44(0)845 330 7201 F: +44(0)870 460 4937 W: www.sbsquared.com E: jlsbsquared.com ********************************************************************* This message (including any attachments) is confidential and may be legally privileged. If you are not the intended recipient, you should not disclose, copy or use any part of it - please delete all copies immediately and notify SBsquared Limited on +44 (0)845 330 7201. SBsquared is registered in England and Wales. Registered Office: Studio 5, The Old Forge, Hoults Estate, Walker Road, Newcastle upon Tyne, NE6 1AB ********************************************************************* -- Smarty Development Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )