View previous topic :: View next topic
|
Author |
Message |
markanthos
New User
Joined: 28 Apr 2005 Posts: 14 Location: India
|
|
|
|
At an HSBC interview I came across the query:
A pic clause is declared as -9(4).999
How many memory locations will this occupy
a)7
b)8
c)9
d)none of the above
and why? |
|
Back to top |
|
|
gnagakishore
New User
Joined: 26 Mar 2005 Posts: 25 Location: Hyderabad
|
|
|
|
it will occupy 8(eight) bytes.
the reason for that is we have to count "." (dot) aslo.
and comming to "-" it wont occupy any memory unless if we stated "sign traling or leading separate character".[/b] |
|
Back to top |
|
|
markanthos
New User
Joined: 28 Apr 2005 Posts: 14 Location: India
|
|
|
|
Thanks a lot |
|
Back to top |
|
|
Deepa.m
New User
Joined: 28 Apr 2005 Posts: 99
|
|
|
|
since it is numeric edited character it will occupy 9 bytes..it will take one byte for '-' sign also.
please advice.
Thanks
Deepa |
|
Back to top |
|
|
avalanches
New User
Joined: 10 May 2005 Posts: 28
|
|
|
|
Deepa,
The sign will occupy the lower nibble of the right most digit.
Cheers,
avalanches |
|
Back to top |
|
|
David P
Active User
Joined: 11 Apr 2005 Posts: 106 Location: Cincinnati Ohio
|
|
|
|
Hi Markanthos,
I agree with deepa that the variable is going to take 9 bytes as storage.
An easy way to find out the lenght of any variable is to have a member (say test) in your copylib pds. Then define that variable whose length you want to find out in this member test. Now save this member and open it in fileaid (option F:8 or H:8 as per your installation). If the definition is syntactically correct you will get the lenght.
Let me know if you have any concerns.
David. |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
even i aslo agree with deepa...i think it will take 9 bytes as it is just a simple declaration...not defined as s9(4).999, in this case it will take i think 8, but when you specify -9(4).999 then it will take 9. |
|
Back to top |
|
|
praveenhj
New User
Joined: 05 Apr 2005 Posts: 6 Location: bangalore
|
|
|
|
hi, i agree with this it will take 9 bytes, not 8 bytes b'coz it id not declared with s9(4).999. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
In this case the sign is called a floating edit char and occupies one byte of storage. |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
So if I colored the reply in RED, it contains error. GREEN means, it is accepted by the moderator. Any Suggestions? |
|
Back to top |
|
|
|