Don't use BigDecimal. It's
EXTREMELY slow. Your problem has nothing to do with needing to represent numbers in an extremely precise manner, it has to do with a lack of understanding for how to deal with floating point numbers.
Here's a simple example to illustrate things you can/
should do instead if you want to get rid of long printout of a double, or other precision issues:
This one deals with rounding to avoid issues with price estimates:
// Some piece of code comes up with an estimate for a limit order price:
// double limitPrice = someFunction();
// this is what it looks like under the hood after
// someFunction() is finished
double limitPrice = 1.220200000000001;
// The following code attempts to submit an order with this price:
myOrder.setOpenPrice ( limitPrice );
// Some code attempts to submit the order:
engine.submitOrder ( "order label", myOrder );
// Throws a JFException because EUR/USD only allows 10ths of a pip, and the price
// calculated above is far too granular
// Instead:
double limitPrice = 1.220200000000001;
// Round limitPrice. Note I used 10000.0 for the division; this is important.
limitPrice = ( (int) ( 10000 * limitPrice ) ) / 10000.0;
// Submit the order
myOrder.setOpenPrice ( limitPrice );
engine.submitOrder ( "order label", myOrder );
// no exception generated
This one deals with printing numbers in a more friendly fashion:
// This prints something similar to: The price is 1.4803030001e+2
System.out.println ( "The price is " + 148.0303000000001 );
// This prints: The price is 148.0303
System.out.format ( "The price is %7.4f\n", 148.0303000000001 );
-Brian