View previous topic :: View next topic
|
Author |
Message |
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
how many bytes will bee allocated for the below variable declaration?
DCL 1 SATZ
3 TAB (2,5),
5 F1 BIN FIXED (15),
5 F2 BIT (16),
5 F3 DEC FIXED (15,7),
5 F4 PIC ‘999V,9‘,
3 F5 PIC ‘(3)9‘;
I found the below but not sure if an array is defined? please help.
F1 = 15 bits
F2 = 16 bits
F3 = 15 bytes
F4 = 4 bytes
F5 = 3 bytes |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
F1 = 16 bits / 4 bytes (allow for the sign bit)
F2 = 16 bits / 4 bytes
F3 = 8 bytes @ 2 digits per byte + the sign nibble
F4 = 5 byte there are 4 digits plus the comma
F5 = 3 bytes
The structure is a two-dimensional array ( TAB (2,5), ) with 10 elements and each instance has the above structure.
Garry |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2153 Location: USA
|
|
|
|
1) 16 bits = 2 bytes, but not 4 of them…
2) even BIN FIXED(5) would require 2 bytes = 16 bits in memory; it’s all rounded to the nearest hardware-supported size
3) DEC FIXED(15,7), and DEC FIXED(14,7) both require the same 8 bytes in memory
4) PIC ‘999’, and PIC ‘S999’ both require the same 3 bytes in memory, because the sign value is compacted with the last digit into the last byte
In general, it is a good idea to learn about data format implementation in the mainframe architecture, to understand this better (if needed). |
|
Back to top |
|
|
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
Garry Carroll wrote: |
F1 = 16 bits / 4 bytes (allow for the sign bit)
F2 = 16 bits / 4 bytes
F3 = 8 bytes @ 2 digits per byte + the sign nibble
F4 = 5 byte there are 4 digits plus the comma
F5 = 3 bytes
The structure is a two-dimensional array ( TAB (2,5), ) with 10 elements and each instance has the above structure.
Garry |
but F5 is in level 3 which is same level as the array declaration.
only the level 5 elements are inside the level 5 TAB?
please explain. thanks in advance. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2153 Location: USA
|
|
|
|
You need align your code properly, to avoid senseless questions in the future
Code: |
DCL 1 SATZ,
3 TAB (2,5), inner group of elements (level 5) repeats 2*5=10 times
5 F1 BIN FIXED (15), one element 2 bytes (16 bits)
5 F2 BIT (16), one element 2 bytes (16 bits)
5 F3 DEC FIXED (15,7), one element 8 bytes
5 F4 PIC ‘999V,9‘, one element 5 bytes
3 F5 PIC ‘(3)9‘; single element after repeated group, 3 bytes |
Now use a calculator, to count the total size.
Take into account the alignment of BIN FIXED(15): if the previous group ended at an odd byte offset, then the following BIN FIXED(15) shall start at the nearest even byte offset, and one extra byte may be skipped. This would not happen when extra attribute UNALIGNED has been used.
Also, a comma was missing in your sample, after SATZ (e.g. SENTENCE?) |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10891 Location: italy
|
|
|
|
did anybody hear about the compile option AGGREGATE
read the manual about the borderline cases where the results might be misleading |
|
Back to top |
|
|
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
sergeyken wrote: |
You need align your code properly, to avoid senseless questions in the future
Code: |
DCL 1 SATZ,
3 TAB (2,5), inner group of elements (level 5) repeats 2*5=10 times
5 F1 BIN FIXED (15), one element 2 bytes (16 bits)
5 F2 BIT (16), one element 2 bytes (16 bits)
5 F3 DEC FIXED (15,7), one element 8 bytes
5 F4 PIC ‘999V,9‘, one element 5 bytes
3 F5 PIC ‘(3)9‘; single element after repeated group, 3 bytes |
Now use a calculator, to count the total size.
Take into account the alignment of BIN FIXED(15): if the previous group ended at an odd byte offset, then the following BIN FIXED(15) shall start at the nearest even byte offset, and one extra byte may be skipped. This would not happen when extra attribute UNALIGNED has been used.
Also, a comma was missing in your sample, after SATZ (e.g. SENTENCE?) |
please explain difference between dec fixed and PIC - both are decimal.
what is a packed numeric data? how to define it? THANKS. (am learning PL1) |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2153 Location: USA
|
|
|
|
In that case you need some basic knowledge of Assembler.
DEC FIXED stands for “packed decimal”, or DS P in Assembler.
PIC stands either for “unpacked decimal” (DS Z in Assembler), or for a “character string” (DS C in Assembler).
I doubt this info might help, unless you start learning something from mainframe concepts. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2153 Location: USA
|
|
|
|
I guess the last time I read any PL/I manual was about 35-40 years ago. But I’m pretty sure all the details you are interested in have been expounded in details in the most part of available manuals.
At least, I personally have got all this information from those manuals - at that time neither web forums, nor Internet itself had been known. |
|
Back to top |
|
|
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
sergeyken wrote: |
I guess the last time I read any PL/I manual was about 35-40 years ago. But I’m pretty sure all the details you are interested in have been expounded in details in the most part of available manuals.
At least, I personally have got all this information from those manuals - at that time neither web forums, nor Internet itself had been known. |
if we all have the time and expertise to read manuals all the time, then there is no need for auto repairshops, painters, electricians, even this blog.
u must be feeling unrecognized.
so here i say it, you are a expert in pl1 and have more knowledge than others, i bet. I also say a BIG THANK YOU for taking the time to help me and ohers in this forum. But there is a reason am working on the weekend with no editor with me.
AGAIN a BIG THANK YOU for helping me understand the declarations.
PLEASE continue to do so. THANK YOU. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2153 Location: USA
|
|
|
|
You might be angry at me, but without a serious learning of the very basic ideas and concepts you are condemned to stuck again and again at every new development step assigned to you.
Just getting a short answer to each separate issue (out of thousands) would not help you to become an expert in any area.
This forum cannot be a schoolbook to explain everything, starting from the very basic concepts. |
|
Back to top |
|
|
|