Last yr I worked at a financial exchange company doing Java EJB. We
wrestled with this issue.  The problem was there an 1800 lb gorilla in
the room called the Federal Government that regulates financial
entities.  We were required to send the feds audit data that they
specify on a daily basis.  If you are off by a penny at the end of a
day, they can shut you down.    We tried float & double with astute
attention to precision.  The only way we could get the everything to
come out right at the end of the day was to use BigDecimal.   Some
developers may have less strict requirements were they can get away
with using Float or Double, some may not.


Tomm Carr wrote:
> 
> Joseph Ottinger wrote:
> 
> > Why do I detect a "Java is slow" post in your future? :) As usual,
> > when you're doing floating point on binary systems, you always have to
> > figure out if it's *really* important to have the precision... and
> > usually, it isn't.
> 
> I'm going from memory so the exact figures may be somewhat off, but I
> remember reading in a Calculus text that, although PI has been
> calculated to thousands or even millions of places, the effort is more
> an academic exercise than a useful pursuit.  Using PI to 9 decimal
> places will give the circumference of the entire universe (assuming one
> knew the exact radius) to within an inch.
> 
> > I'm sure at this point, people are finding woodwork to crawl out of
> > saying, "Yes, it is!" - and you're all correct, for you it's important
> > because you're rocket scientists and all that, and maybe even a
> > financial programmer or two are finding graves to spin in as well.
> 
> In the financial world, the greatest precision (not the same as
> accuracy) is three decimal places -- in dollar/penny currencies, a tenth
> of a penny.  Ivan is about to sacrifice performance on the alter of
> precision because he is confusing precision with accuracy.  What he
> really needs to do is determine exactly how much precision his
> application needs.  I'll bet real money it is a good deal less than the
> precision available with float, much less double.
> 
> > However... I'd still stand by the statement that in most cases, the
> > accuracy simply isn't important enough to justify crippling your
> > program's speed. It's all about the tradeoffs. If it's all about what
> > you SEE, then format the numbers going out instead.
> 
> Aamof, he should be rounding off his results to that precision (usually
> just before storing the finished value after all the calculations have
> been done).  Not just format for printing at that precision, but
> actually discard the unnecessary places.
> 
> Tomm
> 
> To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm


To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to