Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
BIRT SCRIPTING, ROUNDING ERROR
delee88
<p>8812.05 / 2, the answer is 4406.025 and rounded to 2 decimals should be displayed as 4406.03</p><p>Using either method below the result displays as 4406.02.</p><p>Can anyone tell me what I need tp do to have the rounding work as I expected?</p><p>- Thanks
Dale</p><p>1. this.text = df.format( 8812.05 / 2 ) </p><p>2. this.text = BirtMath.round(BirtMath.divide(8812.05 , 2), 2)</p><p>The procedure follows
</p><p>var vID3a = row["CompletedCounseling-ID3a"]
var vIEA = row["CompletedAmount-IE"]
var vIGA = row["CompletedAmount-IG"]
var nrf = row["NRF"]</p><p>var df = new Packages.java.text.DecimalFormat("#,###.##");</p><p>//var rm = new Packages.java.math.RoundingMode();</p><p>//df.setMinimumFractionDigits(2)
//df.setMaximumFractionDigits(2)
//df.setRoundingMode( rm.UP);</p><p>if (nrf == 0 )
{
this.text = "NRF"
}
else if ( vID3a == null|| vIEA == null && vIGA == null )
{
this.text = '###'
}
else if ( vID3a == 0 )
{
this.text = '$' + "0.00"
}
else
{
this.text = '$' + df.format( (vIEA + vIGA ) / vID3a )
// this.text = '$' + BirtMath.round(BirtMath.divide(vIEA + vIGA , vID3a), 2)</p><p> }</p>
Find more posts tagged with
Comments
kclark
<p>Try using Math.ceil() for this</p><pre class="_prettyXprint _lang-">Math.ceil(4406.025 * 100) / 100</pre>