Reputation: 43
I am using Freemarker template,I have a decimal value:
a = 23.65
I just want to retrieve above value as:
a = 23.6 <#-- Extract first number after decimal point -->
I have used number_format ex :
<#setting number_format="0.#">
But it rounded off the value after decimal point to 23.7
.
Could anybody know how to extract first number after decimal point without rounding off?
Upvotes: 1
Views: 2637
Reputation: 5566
You need to use extended formatting option in order to specify a roundingMode
.
Please note, that you need at least FreeMarker 2.3.24 for these to work.
By default freemarker uses halfEven
rounding mode. For your case, you can try to specify down
${(23.65)?string(",##0.0;; roundingMode=down")}
You can check this expression online here.
Upvotes: 2