Es-discuss - several decimal discussions

ihab.awad at ihab.awad at
Sat Aug 23 08:56:47 PDT 2008

On Sat, Aug 23, 2008 at 8:44 AM,  <ihab.awad at> wrote:
> Decimals in Java are implemented at the library level, as
> java.math.BigDecimal. There is no expectation that intrinsic math
> operators work on them. Is this approach valid for ES; if not, then
> why not?

I should add that one approach for doing math formulae on Decimals
that look like intrinsic arithmetic operations is to build, at the
library level, a compiler for functions on decimals. So I could
imagine something like --

  var valueAddedTaxCalc = /* ... */;
  var shippingCostsCalc = /* ... */;

  var totalCost = Decimal.compile(
      { vat: valueAddedTaxCalc, shipping: shippingCostsCalc },
      "function (itemCost, zipCode) { itemCost + vat(itemCost) +
shipping(zipCode); }");

  var basePrice = /* some Decimal number */;
  var total = totalCost(basePrice);

My hypothesis is that decimal calculations are sufficiently localized
that this approach would work; and also, by enforcing strict isolation
between Decimal objects and other number forms, (i.e., not providing
implicit conversions), the necessary hygiene for (say) Sarbanes-Oxley
compliance would be more verifiable by looking at the code.


Ihab A.B. Awad, Palo Alto, CA

More information about the Es-discuss mailing list