|
Bob wrote: >I always thought the "native" format of the AS/400 was packed. And >operations against packed numbers where the fastest. Is this not true? > >Or is it more like: Packed is faster than zoned, but binary/integer is >faster than packed? > >When did this change? Others have already provided good answers. I'll just summarize and add a few points. The AS/400, like the S/38, and practically every other machine out there performs arithmetic fastest in two's complement integer format. RPG II and RPG III offered only decimal numeric data types: Packed, zoned, and binary decimal. For the arithmetic to work the same for all three of these types, the arithmetic was done in packed numeric format. As a result, arithmetic with packed operands was fastest since it didn't involve an additional conversion - the data was already packed. In RPG IV, the situation is a bit more complicated. We have basically four different types of numerics: 1) floating point 2) decimal 3) integer 4) unsigned For the decimal type, there are three formats: packed, zoned, and binary decimal. Altogether six different formats, but conceptually you can put them into these four groups. The way arithmetic works in RPG IV is that if you have operands of different types, the operation is performed in the format of the "bigger" of the two types. If you add together unsigned and decimal fields, for example, the compiler converts both to decimal and the result of the operation is decimal. So basically the rule of thumb for arithmetic in RPG IV is different than in RPG III. If possible, define your numeric fields as integer or unsigned for performance. Use decimal fields only when you're dealing with values with decimal places, such as monetary amounts. Yes, you can store the most precision using decimal, but now if you're on V4R4, you can use 8-byte integer and unsigned fields, which give you about 19 digits. And since the machine is 64-bit, you'll find that the 8-byte integer and unsigned types perform practically the same as the 4-byte I/U types. Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-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-2025 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.