Binary coded decimal numbers (OMBCD)

You can use the OMBCD library to create and manipulate BCD (Binary Coded Decimal) numbers in your programs.

BCD numbers are useful for financial calculations.

The syntax of most BCD functions is the same as that for the corresponding floating point functions, and you can safely import both of them—omfloat.xmd and ombcd.xmd—in a single OmniMark program.

There are several categories of external functions in the OMBCD library, all of which use the same operators as in the OMFLOAT library and in core OmniMark:

  • basic arithmetic functions,
  • comparison operators,
  • functions for rounding numbers, and
  • exponential functions.

You can do output of all BCD numbers by using the OmniMark template formatting language or by using the format operator ("d" %).

Usage Note

To use OMBCD, you must import it into your program using an import declaration such as:

  import "ombcd.xmd" unprefixed

OMBCD Generated Exceptions

This is a complete list of the OMBCD library external exceptions that may be thrown back to the calling OmniMark program. These are all catchable using the #external-exception label.

  • BCD0002: String is Not a Valid BCD Value
  • BCD0010: Format Command Not Supported
  • BCD0011: Format Modifier Not Supported
  • BCD0012: Illegal Template Character
  • BCD0013: Template Overflow
  • BCD0014: Illegal Format String
  • BCD0020: Divide By Zero
  • BCD0021: Zero Raised to the Power Zero
  • BCD0022: Illegal Modulus
  • BCD0023: Illegal Rounding Base
  • BCD0030: Out Of Memory