user20873: a user submits a buy request: 0.0104 BTC at a rate of 345.92 EUR
config:
var mode = RoundingMode.HALF_EVEN();
var satoshi = new BigDecimal("100000000");

user input:
var btc_b = new BigDecimal("0.0104");
var rate_b = new BigDecimal("345.92");

convert amount to smallest unit:
var btc_s = btc_b.multiply(satoshi);

btc * rate = spend:
var eur_s = btc_s.multiply(rate_b).setScale(0,mode);
console.log(eur_s.longValue());

output: 359756800

eur / smallest unit:
var eur_b = eur_s.divide(satoshi, 8, mode);
console.log(eur_b.longValue());

output: 3.597568

but since eur has only 2 decimals:
console.log(eur_b.setScale(2,mode).longValue());

output: 3.6

i assume the user must spend 3.6 EUR for 0.0104 BTC at a rate of 345.92 EUR
here's a fiddle: jsfiddle.net/nvkja98c/
please correct me if i'm wrong!

user20877: This is not a rounding problem.  The 3.6 EUR is correctly rounded to two decimals from 3.597568 EUR.  
Computers don't know when we want to see trailing zeros.  The problem is formatting:
console.log(eur_b.setScale(2,mode).longValue().toFixed(2));

output: 3.60

(fiddle)

20873: <p>a user submits a buy request: 0.0104 BTC at a rate of 345.92 EUR</p>

<p>config:</p>

<pre><code>var mode = RoundingMode.HALF_EVEN();
var satoshi = new BigDecimal("100000000");
</code></pre>

<p>user input:</p>

<pre><code>var btc_b = new BigDecimal("0.0104");
var rate_b = new BigDecimal("345.92");
</code></pre>

<p>convert amount to smallest unit:</p>

<pre><code>var btc_s = btc_b.multiply(satoshi);
</code></pre>

<p>btc * rate = spend:</p>

<pre><code>var eur_s = btc_s.multiply(rate_b).setScale(0,mode);
console.log(eur_s.longValue());

output: 359756800
</code></pre>

<p>eur / smallest unit:</p>

<pre><code>var eur_b = eur_s.divide(satoshi, 8, mode);
console.log(eur_b.longValue());

output: 3.597568
</code></pre>

<p>but since eur has only 2 decimals:</p>

<pre><code>console.log(eur_b.setScale(2,mode).longValue());

output: 3.6
</code></pre>

<p>i assume the user must spend 3.6 EUR for 0.0104 BTC at a rate of 345.92 EUR</p>

<p>here's a fiddle: jsfiddle.net/nvkja98c/</p>

<p>please correct me if i'm wrong!</p>
 20877: <p>This is not a rounding problem.  The 3.6 EUR is correctly rounded to two decimals from 3.597568 EUR.  </p>

<p>Computers don't know when we want to see trailing zeros.  The problem is formatting:</p>

<pre><code>console.log(eur_b.setScale(2,mode).longValue().toFixed(2));

output: 3.60
</code></pre>

<p>(<a href="http://jsfiddle.net/x90f3p5x/" rel="nofollow">fiddle</a>)</p>
