× 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.



> >4) All of the 9B0 variables should really be 10I0.
> > (There's really no good reason any more for
> > using binary decimal variables.)
>
> I ran into some problems when I used 10I0 vs
> 9B0 so that is why I am cautious of using 10I0.

What problems?  I can only imagine the problems in reverse; that is, using
the 'B' type variables in API calls rather than 'i' type.

> This may be a wives tale, but I heard that
> if an API uses 4B0 it should convert to 5I0 and
> if it uses 9B0 it should convert to 10I0.

There's a huge nomenclature issue that needs to be resolved.  The FAQ might
help (What does 'Binary 4' mean in API documentation?)
http://faq.midrange.com  Basically, 'Binary 4' means a 4 byte integer.  RPG
represents that integer value as '10i 0' which translates into 'ten digit
variable, integer data type (and maximum value.)'  A full 4 byte integer can
hold a maximum value of 2^31 (4 bytes * 8 bits, minus 1) 2,147,483,648  The
RPG 'b' data type can only hold 9 digits, which means that the high-order
digit (here, a 2) will be silently truncated.

Binary 2 translates into 5i 0 for the same reason.  Two bytes = 15 bits =
32,768: 5 digits.  The equivalent 'b' data type of 2b 0 will truncate off
the high order digit.

Be very aware that there are two distinct ways to specify a variable's
length: implicitly and explicitly.  An implicit 4 byte integer would look
like '1 4b 0', from which you would deduce that it is 4 bytes long, meaning
10 digits.  You undergo a similar translation when you think of packed
numbers like '1 5p 0' which is 5 bytes, and 9 digits long.  The other way to
specify these is to specify the length and let the compiler figure out how
many bytes they will occupy.  Respectively, that would by '10i 0' and '9p 0'
The documentation always refers to the number of BYTES the variable should
occupy, and NOT the number of digits.

Hope that was of some help.  Barbara's explanation in the FAQ is better than
mine, but I got a respite from work and the fingers took on a life of their
own.

Oh, and Hans - I know you won't be removing the 'b' support, but there is
one good reason to use the old 'b' data type, and that is program described
file specs which look something like this '1 4b2'  The integer data type
doesn't support decimals, but the old 'b' does.  Sigh.  The things us old
timers have to put up with!
  --buck




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.