Saturday, July 30, 2016

Zoned Decimal and packed Decimal (COMP- 3) fields. How Does COMP 3 saves storage space?

Two computer codes which are used  for internal representation of data are EBCDIC and ASCII.
Extended Binary coded decimal interchange(EBCDIC)  code is a 8 bit character encoding standard used in IBM environment.
Most of the other Non IBM machines use ASCII standard.
Below is the EBCDIC representation of the alphabets and numbers followed in IBM environment.
EBCDIC represenation of Aphabets and Numerals

Following the chart, we can see 'a' (2nd row in above chart)  is represented in binary in 1000000001 and has the hex value of  81.

 All characters & numbers are represented in 8 bits. These 8 bits can be  broken into two 4 bit segments. For historical reasons, the  high order 4 bits are called zone part and low order 4 bits are called digits part.
Each of these 4 bits are represented by one hexadecimal character. Thus each 8 bit EBCDIC can be represented by  two character hexadecimal value. The high order 4 bits are used to represent whether the value stored is a letter,positive or negative number. Low order 4 bits represents numbers 0-9.

Let us see how the letter D is stored internally.(Map with the chart above)

In similar fashion, we can see how the letter 8 will be stored in the system( Map with the chart above)

Thus we see that in zoned decimal each byte represents one digit.

So, how will the positive number 62587 be stored in the system?
Zoned decimal number in EBCDIC repreentaion
In  zoned decimal, the zone portion of the rightmost byte represents the sign of the number.
For positive number, the zone portion is always 1111.
For negative number the zone portion becomes  1101.
Thus -6 can will be represented  as: 1101(Zone part) 0110(Digit part)

Packed Decimal fields: How does it save spaces?  Let's see how it works.

In  packed decimal format, the zone portion is stripped from each byte, so that two digits can be packed together in one byte.This way the space for zone portion of each byte can be used to represent another digit. Thus two digits are represented in single byte there by saving the space.
Only the zone portion of the low order or the rightmost byte is kept for storing the sign of the field.
Considering the same example, see how the number 62587 will be stored in packed decimal format.
Space utilized will be reduced from 5 bytes to 3 bytes.

Number :                                6               2              5             8                7
Packed decimal representation
We can see that two digits are packed in single byte by stripping of the zone portion of all the bytes except the last byte (marked in brown).
Had it been a negative number the last byte would have contained 1101 in place of 1111.

This way, a packed decimal number saves space by packing two digits in one byte.


37 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

      IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

      corporate training in chennai corporate training in chennai

      corporate training companies in india corporate training companies in india

      corporate training companies in chennai corporate training companies in chennai

      I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai

      Delete
  2. Note.
    When positive number, either packed or unpacked, is produced as result of a machine instruction, the zone portion for positive numbers is always created as B'1100'=X'C'; the zone portion for negative numbers is always produced as B'1101'=X'D'.
    When a decimal value, either packed or unpacked, is prepared in some different way except as result of machine instruction, also other zone portion values are acceptable:
    - zone portions X'D', X'E', and X'B' are considered as "minus" sign for negative decimal value,
    - zone portions X'C', X'F', and X'A' are considered as "plus" sign for positive decimal value.

    ReplyDelete
    Replies
    1. Hi . Thanks for your valuable points mentioned above. It really improves our knowledge base.

      Delete
  3. Nice explanation...!!

    ReplyDelete
  4. I really appreciate the information shared above. It’s of great help. If someone wants to learn Online (Virtual) instructor lead live training in IBM Mainframe TECHNOLOGY, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor-led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ pieces of training in India, USA, UK, Australia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Pratik Shekhar
    MaxMunus
    E-mail: pratik@maxmunus.com
    Ph:(0) +91 9066268701
    http://www.maxmunus.com/

    ReplyDelete
  5. Very nice posting. Your article us quite informative. Thanks for the same. Our service also helps you to market your products with various marketing strategies, right from emails to social media. Whether you seek to increase ROI or drive higher efficiencies at lower costs, Pegasi Media Group is your committed partner will provide b2bleads.
    IBM Mainframe Users


    ReplyDelete
  6. Using this answer i answered for in hcl interview.Realy excellant and good.Same question faced while i attend Mainframe Training in Chennai.

    ReplyDelete
  7. I read the post and I have really enjoyed your blogs posts.looking for the next post.
    Digital Marketing Training In Bangalore.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. quite informative, thanks for sharing with us

    if you are interesting in reading my blogs
    read this -http://www.learndigital.co/

    ReplyDelete
  10. quite informative, thanks for sharing with us

    if you are interesting in reading my blogs
    read this - http://www.learndigital.co/

    ReplyDelete
  11. Keep blogging.!!
    Your blog is very unique and interesting. It makes reader to come back and visit again.
    Villas in Goa
    python training in Vijaynagar

    ReplyDelete
  12. I’m planning to start my blog soon, but I’m a little lost on everything. Would you suggest starting with a free platform like Word Press or go for a paid option? There are so many choices out there that I’m completely confused. Any suggestions? Thanks a lot.
    Best AWS Training in Marathahalli | AWS Training in Marathahalli
    Best AWS Amazon Web Services Training in Chennai | Best AWS Training and Certification for Solution Architect in Chennai

    ReplyDelete
  13. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
    python training in rajajinagar
    Python training in bangalore
    Python training in usa

    ReplyDelete
  14. I always enjoy reading quality articles by an individual who is obviously knowledgeable on their chosen subject. Ill be watching this post with much interest. Keep up the great work, I will be back

    Java training in Chennai | Java training in Omr

    Oracle training in Chennai

    Java training in Chennai | Java training in Annanagar

    Java training in Chennai | Java training institute in Chennai | Java course in Chennai

    ReplyDelete
  15. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    rpa training in chennai
    Best rpa training in bangalore
    rpa course in bangalore
    rpa training in marathahalli
    rpa training in btm
    best rpa training in chennai

    ReplyDelete
  16. Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
    Best Devops online Training
    Online DevOps Certification Course - Gangboard

    ReplyDelete
  17. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    AWS TRAINING IN BANGALORE|NO.1AWS TRAINING INSTITUTES IN BANGALORE |AWS COURSE TRAINING IN BANGALORE

    ReplyDelete
  18. Nice Post! It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    NEET Coaching Classes

    ReplyDelete
  19. Explain how to represent a single digit decimal number by using Zone decimal representation.

    ReplyDelete



  20. INSTEAD OF GETTING A LOAN,, I GOT SOMETHING NEW
    Get $10,050 USD every week, for six months!

    See how it works
    Do you know you can hack into any ATM machine with a hacked ATM card??
    Make up you mind before applying, straight deal...
    Order for a blank ATM card now and get millions within a week!: contact us
    via email address:: besthackersworld58@gmail.com or whats-app +1(323)-723-2568

    We have specially programmed ATM cards that can be use to hack ATM
    machines, the ATM cards can be used to withdraw at the ATM or swipe, at
    stores and POS. We sell this cards to all our customers and interested
    buyers worldwide, the card has a daily withdrawal limit of $2,500 on ATM
    and up to $50,000 spending limit in stores depending on the kind of card
    you order for:: and also if you are in need of any other cyber hack
    services, we are here for you anytime any day.
    Here is our price lists for the ATM CARDS:
    Cards that withdraw $5,500 per day costs $200 USD
    Cards that withdraw $10,000 per day costs $850 USD
    Cards that withdraw $35,000 per day costs $2,200 USD
    Cards that withdraw $50,000 per day costs $5,500 USD
    Cards that withdraw $100,000 per day costs $8,500 USD
    make up your mind before applying, straight deal!!!

    The price include shipping fees and charges, order now: contact us via
    email address::besthackersworld58@gmail.com or whats-app +1(323)-723-2568

    ReplyDelete

  21. Do you need personal loan? Does your firm,company or industry need financial assistance? Do you need finance to start your business? Do you need finance to expand your business? We give out loan to interested individuals who are seeking loan with good faith. Are you seriously in need of an urgent loan contact us at Email:fastestloaninvestment@gmail.com
    APPLICATION DETAILS
    Your Full Details:
    Full Name:
    Loan Amount Need:
    Loan Duration:
    Phone Number:
    Applied before?
    State:
    Monthly Income:
    Country:
    You are to send this to our Company Email Address fastestloaninvestment@gmail.com

    ReplyDelete
  22. Is a software job your dream? Then we, Infycle Technologies, are with you to make your dream into existence. Infycle Technologies is the Best Software Training Institute in Chennai, which offers multiple courses such as Oracle, Python, Java, AWS, etc., with 100% practical training besides specialized trainers in the field. Furthermore, the mock interviews will be arranged for the students to face the job interviews without any fear. Additionally, 100% placement assurance will be given here. Call 7502633633 to Infycle Technologies and grab a free demo to know moreBest Software Training Institute in Chennai | Infycle Technologies

    ReplyDelete
  23. Learn Amazon Web Services for excellent job opportunities from Infycle Technologies, the Excellent AWS Training in Chennai. Infycle Technologies gives the most trustworthy AWS course in Chennai, with full hands-on practical training from professional trainers in the field. Along with that, the placement interviews will be arranged for the candidates, so that, they can meet the job interviews without missing them. To transform your career to the next level, call 7502633633 to Infycle Technologies and grab a free demo to know more

    ReplyDelete
  24. Great post. MuleSoft Training in Canada is a best institute for training.

    ReplyDelete
  25. Infycle Technologies, the No.1 software training institute in Chennai offers the No.1 Big Data Hadoop Training in Chennai | Infycle Technologies for students, freshers, and tech professionals. Infycle also offers other professional courses such as DevOps, Artificial Intelligence, Cyber Security, Python, Oracle, Java, Power BI, Selenium Testing, Digital Marketing, Data Science, etc., which will be trained with 200% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7502633633 to get more info and a free demo.

    ReplyDelete
  26. Infycle Technologies, the No.1 software training institute in Chennai offers the best Big Data Hadoop training in Chennai for students, freshers, and tech professionals. Infycle also offers other professional courses such as DevOps, Artificial Intelligence, Cyber Security, Python, Oracle, Java, Power BI, Selenium Testing, Digital Marketing, Data Science, etc., which will be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7502633633 to get more info and a free demo.Grab Big Data Hadoop Training in Chennai | Infycle Technologies

    ReplyDelete
  27. Grab the Digital Marketing Training in Chennai from Infycle Technologies, the best software training institute, and Placement center in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Cyber Security, Big Data, Java, Hadoop, Selenium, Android, and iOS Development, DevOps, Oracle, etc with 100% hands-on practical training. Dial 7504633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.

    ReplyDelete
  28. Wow! I was seeking such site that might provide me with Assignment Help because I had no idea what I was supposed to do with my assignment and had decided to look for any service that could help me finish it. But, now I'm confident that this post will much assist me in completing my project on my own.

    ReplyDelete