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



Hi,

Thanks for the wonderful explanation.
Am just curious why the IntNum is declared as 5 digit integer, any specific
reasons ?


Gauri.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of
david.kahn@xxxxxxxxxxxxxxxxx
Sent: Thursday, January 19, 2006 5:17 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: How come this returns a decimal value ... ?


"Gauri Kulkarni" <gauri.kulkarni@xxxxxxxxx> wrote:

>> D IntDS DS
>> D IntNum 5I 0 INZ(0)
>> D IntChar 1 Overlay(IntNum:2)
>> *
>> C MOVE X'C0' IntChar
>>
>> Now, IntNum will contain 192.
>
> But, not very well aware of OVERLAY keyword, so wondering
> how this might have returned a decimal value in 'IntNum'.
> Can anybody please help in getting this point ?

IntNum is defined as a 5-digit integer. Internally it is stored in binary
format and occupies 2 bytes of storage. The Overlay keyword tells the
compiler that IntChar is to occupy the same portion of memory as IntNum.
The 2 following the colon specifies that the first position of IntChar -
which is only one character long - occupies the same memory location as
position 2 of IntNum.

The data structure is therefore 2 bytes long, and because IntNum is
initialised to zero, and IntNum is in binary format, it initially contains
x'0000'.

IntChar occupies the 2nd byte of the data structure so moving x'C0' to it
means the data structure now contains x'00C0'.

The value of IntNum is now 192 because it is in binary format and x'00C0'
is '0000000011000000' in binary. This is 128 + 64 = 192. Note you can
calculate the decimal value directly from the hexadecimal: (4096 x 0) +
(256 x 0) + (16 x 12) + (1 x 0) = 192.

--
Dave...


______________________________________________________________________
This message may contain confidential information which may also be legally
privileged and is intended only for the use of the parties to whom it is
addressed. If you are not an intended recipient you are hereby notified that
any disclosure, copying, distribution or use of any information in this
e-mail is strictly prohibited. If you receive this message in error please
notify the sender by return e-mail and then destroy it. Further, we make
every endeavour to keep our network free from viruses. However, you do need
to verify that this e-mail and any attachments are free of viruses as we can
take no responsibility for any computer viruses which might be transferred
by way of this e-mail. All information and attachments remain the property
of Stolt Offshore Group and should be held as confidential.
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@xxxxxxxxx and delete this mail. 
_____________________________________________________________________

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.