|
Jim wrote: >Okay, let me just say it this way then, it is not safe to do ANY type >of math on any number that contains a fraction. > >If I have to worry about loosing accuracy after ONE significant digit, >something is definitely wrong with the math engine. Jim: Have you studied Chapter 21 of the ILE RPG Reference manual? You want decimal arithmetic to be done precisely regardless of the size of the value? Here's how to do it: Do your arithmetic in a REXX program with the following statement: NUMERIC DIGITS 1000 (If a thousand digits isn't good enough, just change it to a bigger number.) But guess what the performance of your program will be like? Although the performance of interpreted languages is becoming a less significant factor in choice of programming language, most shops tend to prefer the performance advantages of compiled languages. But these performance advantages come with constraints, such as RPG's 30 digit maximum on the precision of decimal values. (Or IEEE's design of floating point values, which limits precision to no more than 17 digits, at best.) I take issue with your assertion that it is not safe to do ANY type of math on any number that contains a fraction. (I'm sure the vast majority of programmers who do code their arithmetic in expressions would also disagree!) The rules for decimal arithmetic in expressions are documented in Chapter 21 of the ILE RPG Reference. If you want to be able to code decimal expresssions safely, you need to understand those rules. If you still have questions after studying Chapter 21, I'd be quite happy to answer them. You could always stick to the traditional ADD, SUB, MULT, etc opcodes. But since the default behavior of those is to truncate results instead of failing on numeric overflow, those opcodes are the real unsafe ones! Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.