title: kotlin rounding off in BigDecimal
body: <pre><code>import java.math.BigDecimal
  
  BigDecimal(0.235).setScale(2, BigDecimal.ROUND_HALF_UP) // 0.23
  
  BigDecimal(&quot;0.235&quot;).setScale(2, BigDecimal.ROUND_HALF_UP) // 0.24
  </code></pre>
  <p>In kotlin, when input 0.235 is given as double then the output is 0.23.
  when input 0.235 is given as string then the output is 0.24</p>
  <p>Here is the definition of ROUND_HALF_UP given in the documentation:</p>
  <blockquote>
  <p>Rounding mode where values are rounded towards the nearest
  neighbor. Ties are broken by rounding up.</p>
  </blockquote>