While moving a decimal value to Comp-5, you just need to consider these: it stores only the integer portion and ignores the decimal portion.

Suppose you have defined a field with PIC 9(07)V99 and you moved a value from this data type to COMP-5.

COBOL Example: How to use COMP-5.

01 My-data     PIC 9(07)v99 value 1234567.10.
01 Out-data    comp-5 or S9(07)v99 Comp-5.
   MOVE My-data   to  Out-data.

The result will be: 1234567

Resolution

The key point I want to share is that Comp-5 stores only integer parts and truncates decimal parts.

Note: So, you cannot use comp-5 as S9(07)v99, but you can use it as S9(09).

More details of COMP-5

  • Comp-5 stores the data in the form of Binary ( because binary doesn’t support decimals)
  • It has boundaries. It stores as 2/4/8 bytes internally
  • S9(1) to S9(4) => 2 bytes(half)
  • S9(5) to S9(9) ==> 4 bytes(full)
  • S9(10) to S9(18) ==> 8 bytes(double)
  • With or without ‘S’ you can define the Comp-5 data types

References

LATEST POSTS

How a PySpark Job Executes: Understanding Statements, Stages, and Tasks

When you write a few lines of PySpark code, Spark executes a complex distributed workflow behind the scenes. Many data engineers know how to write PySpark, but fewer truly understand how statements become stages, stages become tasks, and tasks run on partitions. This blog demystifies the internal execution model of Spark by connecting these four…

Azure Data Factory (ADF): The Complete Beginner-Friendly Guide (2026 Edition)

Azure Data Factory (ADF) is Microsoft’s fully managed, cloud-based data integration and orchestration service. It helps you collect data from different sources, transform it at scale, and load it into your preferred analytics or storage systems. Whether you are working with Azure SQL, on-premises databases, SaaS applications, or big-data systems, ADF gives you a unified…

Something went wrong. Please refresh the page and/or try again.