Binary-coded decimal built-in functions

Binary-coded decimal (BCD) values are compressed, with each decimal digit and sign bit occupying 4 bits. Digits are ordered right-to-left in the order of significance, and the final 4 bits encode the sign. A valid encoding must have a value in the range 0 - 9 in each of its 31 digits and a value in the range 10 - 15 for the sign field.

Source operands with sign codes of 0b1010, 0b1100, 0b1110, or 0b1111 are interpreted as positive values. Source operands with sign codes of 0b1011 or 0b1101 are interpreted as negative values.

BCD arithmetic operations encode the sign of their result as follows: A value of 0b1101 indicates a negative value, while 0b1100 and 0b1111 indicate positive values or zero, depending on the value of the preferred sign (PS) bit. These built-in functions can operate on values of at most 31 digits.

BCD values are stored in memory as contiguous arrays of 1-16 bytes.

Note: Clang-based front end beginsTo use the BCD format conversion functions, you must include the bcd.h file and set -qarch to utilize POWER9 technology.Clang-based front end ends To use other types of BCD functions including the following ones, you must Clang-based front end beginsinclude the altivec.h file andClang-based front end ends specify -qaltivec:
  • BCD add and subtract functions
  • BCD comparison functions
  • BCD load and store functions
  • BCD test add and subtract for overflow functions
Clang-based front end begins

Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us