× 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: [Re: RPGILE V4.3 Gotcha]
  • From: boldt@xxxxxxxxxx
  • Date: Tue, 12 Oct 1999 09:01:26 -0400



I know David asked us to drop non-RPG related topics.  But then again,
many RPG programmers also do a bit of C programming, and some of the
issues are the same in both languages.

Jim wrote:
>You forgot something, the range of a short integer in C is -32768 to 32767
>because of the sign bit.

I don't mean to nitpick, but it's only some implementations that
define "short integer" to mean "16 bit integer".  The C standard
makes no such definition.  All that's required of a C compiler is
sizeof(short) <= sizeof(int) <= sizeof(long).

Making assumptions on the sizes of things can get you into trouble
when porting C code.

>When you assign the value 65100 to the variable
>A it is taking the high bit (32768) and making it the sign bit.
>
>Also, in Intel integers are stored in what is called "2's compliment".  The
bit's
>are reversed and 1 is added (don't ask me why, it was explained to me once
>but didn't make much sense).

Think of 2's complement like running a cars odomoter backwards.
Let's count downwards using 8-bit ints as an example, 00000011 (3),
00000010 (2), 00000001 (1), 00000000 (0), 11111111 (-1),
11111110 (-2), etc.  Compare to the odomoter:  counting back
from 0000000 you then get 9999999.

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