1

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?

Oleg
  • 6,124
  • 2
  • 23
  • 40
Naveen
  • 43
  • 2
  • 9

1 Answers1

2

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.

VadymVL
  • 5,366
  • 3
  • 26
  • 41