Joseph Ottinger wrote: > I used to work in financials as well (for the State of Florida) where > we, too, had to balance out to the penny. We did so with COBOL, and > managed portions ourselves. It *can* be done. :)
Right. Any spec is going to have an error tolerance in it. There is no such thing as absolute accuracy. I don't think there is even a definition of absolute accuracy. Even the feds can't demand something that doesn't exist. However, demanding accuracy to the nearest penny is certainly within the capabilities of a 64-bit double floating point data type. If not, how would they even know your calculation was off by a penny? Do they test it with 128-bit floats? So why does Java have BigInteger and BigDecimal? For the padded cell crowd that want to calculate pi or e or Plank's Constant to the millionth decimal place. But their real-world usefulness is limited. Limited does not mean non-existant. I have a calculation that uses Fibonacci values which can get quite large quickly. So, during that part of the calculation, I use BigInteger. Even in this one place I use it I could probably get away with using doubles to hold large integer values, but this is such a small part of the overall calculation which is such a small part of the total application that the performance hit is negligible so why not? Another application which could use BigInteger during intermediate processing is statistics. There are many statistical equations which use factorials. The final answers are quite reasonable in scope, but the intermediate calculations use very large values. All this means is that the usefulness if BigInteger and BigDecimal are restrictive and, if used, should be limited only to where they are essential. To adopt the use of BigDecimal for all floating point calculations, as the original poster implied he might do, just to obtain an arbitrary level of precision is unnecessary. Btw, if BigDecimal can be an arbitrary length, what is returned when you divide 1 by 3 using BigDecimal? There has to be some point in generating the sequence of 9's where even BigDecimal has to call it quits. Tomm To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm
