Re: BUG! Erratic for loop behavior
- Posted by petelomax at blueyonder.co.uk Mar 24, 2002
- 475 views
On Sun, 24 Mar 2002 16:45:00 +0000, Chris Bensler <bensler at mail.com> wrote: >This seems like a devastating problem. We use fractional numbers all the >time. How is it possible that it doesn't show up more often? > >Do we need to resort to binary math? Would that even help? > >What can be done to ensure that my program is calculating the math >properly? > See http://www2.hursley.ibm.com/decimal/ I think that's what is needed, There is even some C code there. It is IEEE854 rather than IEEE754. What does everyone else think? I should specifically mention the following extracts: Complaints about the performance of decimal arithmetic are extremely common. Software emulation is 100 to 1000 times slower than a hardware implementation could be. For example, a JIT-compiled 9-digit BigDecimal division in Java takes over 13,000 clock cycles on an Intel Pentium. Even a simple 9-digit decimal addition takes at least 1,100 clock cycles. In contrast, a native hardware decimal type could reduce this to a speed comparable to binary arithmetic (39 cycles). Almost all major IBM language products support decimal arithmetic, including C (as a native data type, on z900), C++ (via libraries), COBOL, Java (through the Sun or IBM BigDecimal class), OS/400 CL, PL/I, PL/X (on AS/400), NetRexx, PSM (in DB2), Rexx, Object Rexx, RPG, and VisualAge Generator. Many other languages also support decimal arithmetic, including Microsoft’s Visual Basic and C# languages (both of which provide a floating-point decimal arithmetic using the .Net runtime Decimal class). Pete