Binary
Binary is the base-2 number system, using only two symbols: 0 and 1. On IBM mainframes and z/OS, all data, including numeric values, character strings, and machine instructions, are fundamentally represented and processed in binary form by the hardware. It is the lowest-level language understood by the `CPU`.
Key Characteristics
-
- Base-2 System: Utilizes only two digits, 0 (off) and 1 (on), directly mapping to the electrical states within the computer's circuitry.
- Fundamental Unit (Bit): The smallest unit of data, a single binary digit (0 or 1), which forms the basis for all data representation.
- Data Groupings: Bits are grouped into larger units: a
byte(8 bits), ahalfword(2 bytes or 16 bits), afullword(4 bytes or 32 bits), and adoubleword(8 bytes or 64 bits), which are standard addressing and processing units on z/Architecture. - Signed and Unsigned Representation: Binary numbers can represent both positive and negative integers, typically using two's complement for signed integers on z/OS.
- Fixed and Floating Point: Binary is used for both fixed-point arithmetic (integers) and floating-point arithmetic (real numbers), with specific hardware instructions for each.
Use Cases
-
- Internal Data Representation: All data stored in memory, registers, or on disk (e.g., files, databases) is ultimately stored as a sequence of binary digits.
- Machine Code and Instructions: The
CPUexecutes instructions that are encoded in binary, where specific bit patterns represent opcodes and operands for operations like addition, subtraction, or data movement. - Bit Flags and Masks: Programmers, especially in
Assembleror low-levelCOBOLoperations, use individual bits or bit patterns within a byte or word to represent logical flags (e.g., status indicators) or to mask specific portions of data. - Address Calculation: Memory addresses are binary numbers, and the
CPUuses binary arithmetic to calculate effective addresses for data access. - Logical Operations: Binary logic (AND, OR, XOR, NOT) is fundamental to how the
CPUperforms comparisons, data manipulation, and control flow.
Related Concepts
Binary is the bedrock upon which all other mainframe data representations are built. While users and applications often interact with EBCDIC characters or packed decimal numbers, these are merely higher-level abstractions that the system converts to and from binary for processing. Assembler language directly manipulates binary data, registers, and memory addresses, providing the closest interface to the machine's binary operations. COBOL data types like COMP (binary) and COMP-5 (native binary) specify how numeric data is stored and processed, with COMP directly mapping to binary integer formats, leveraging the hardware's native capabilities.
- Choose Appropriate Data Types: For numeric computations, use
COMP(binary) orCOMP-5(native binary) inCOBOLfor integer arithmetic when performance is critical, as these map directly to hardware binary operations, avoiding conversion overheads associated withpacked decimalorzoned decimal. - Understand Data Alignment: Be aware of
boundary alignmentrequirements for binary