Introduction

If you *ever* worked with java.math.BigDecimal in the past, then you will probably acknowledge that - even though BigDecimal is very powerful - it is not very 'developer-friendly'. Through all of the different BigDecimal operations and objects being constructed, it is easy to loose track of the actual calculation.

One of the biggest problems with BigDecimal is that you cannot just apply ordinary mathematical operators. Instead, developers are required to take simple formulas apart and turn them into several pages of awkward Java code, in which every operation generates a new immutable BigDecimal object. BigNumbers tries to solve this; it will allow you to express a simple calculation like '(a / 20) * (b + 123.90)' in exactly the same way as we're giving it here. Note that the BigDecimal calculation would be something like this:

/** 
 * Calculates (a / 20) * (b + 123.90) 
 */ 
public void calculateIt(BigDecimal a, BigDecimal b) { 
  BigDecimal v1 = new BigDecimal("123.90"); 
  BigDecimal v2 = v.add(b); 
  BigDecimal v3 = new BigDecimal("20"); 
  BigDecimal v4 = a.divide(v3, BigDecimal.ROUND_HALV_EVEN); 
  BigDecimal v5 = v2.multiply(v4); 
  return v5; 
} 

Also note that BigNumbers does *not* replace BigDecimal. Instead, it will act as an easy front-end to BigDecimal. (Just look at it as a simple domain specific language.) The intent is to have several compilers and interpreters.