× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: MIDRANGE-L Digest V2 #689
  • From: Jon.Paris@xxxxxxxxxx
  • Date: Fri, 13 Nov 1998 12:24:22 -0500

The original RPG B(inary) data type - like it's COBOL equivalent - wants to
constrain the value that it represents to a whole number of digits.  For
example a 2 byte integer can hold values up to 32K, however if you were to
try to define a 5 digit binary field in RPG, you would find that the
compiler would allocate 4 bytes not 2.  This is because the value 99,999
(i.e. the largest 5 digit number) cannot be contained within 2 bytes.  So,
if you define it as being a 4B field, then if the API (or whatever) returns
a value larger than 9,999 it would be truncated with unpredictable results.
If you define the field as 5I however, there is no truncation possible.

An additional benefit is performance - in order to ensure that the B field
contains only the permitted number of digits, it is 'filtered' through a
packed decimal field of the required number of digits.  To be honest I'm
not 100% certain that the RPG compiler always does this - I know the COBOL
compiler does and the 'rules' are the same.


>Jon,
>Could you explain why this is?

>Bill

>> I doubt it has any relevance to your problem, but I notice you define
all
>> of the binary fields as type B.  This is not a good idea - you should be
>> using type I(nteger) i.e. 10 I  0  (not 9 B 0).


+---
| 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 thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.