Interface Repository

# Module BCD

## Types

• Binary

A generic octet sequence type.

```    typedef sequence < octet > Binary;
```

• Decimal

```    struct Decimal
{
BCD::Binary value;
};
```

A floating-point decimal type.

The `Binary` representation of floating-point values is designed to support easy conversion to and from strings, while at the same time minimising the size of the binary representation for GIOP.

A number is converted to the binary representation using the following algorithm.

• Convert the number to a decimal string, with a leading '-' if negative, and no leading sign if zero or positive.
• The string may contain a decimal point. If the number's scale is greater than zero, the decimal point is followed by the number's decimal fraction. The number of digits in the fraction indicates the scale; trailing zeroes should not be truncated as that would reduce the implied scale.
• Convert the string's characters to an octet sequence where each half-octet represents padding, a decimal digit, negative sign, or decimal point, as follows:
• If the string length is odd, the initial half-octet value is 12. This is used as padding to ensure an even number of half-octets.
• '0' to '9' map to half-octet values 0 to 9.
• '.' maps to half-octet value 10.
• '-' maps to half-octet value 13.
• In each octet of the sequence, the most significant half-octet is filled first. Thus the value "-9" would be encoded as octet value `13 * 16 + 9 = 217`.

Any program receiving a binary value which is not formed according to the above specification should raise a CORBA::DATA_CONVERSION system exception.

Note: a struct is used because it allows overloaded methods to be defined in C++ and Java for decimal manipulation. It also guarantees that a distinct type is generated for the Java IDL language mapping.

• Money

```    struct Money
{
BCD::Binary value;
};
```

A floating-point decimal (money) type. Uses the same representation as `Decimal` but may be used where a semantic distinction is required.

Note: a struct is used because it allows overloaded methods to be defined in C++ and Java for money manipulation. It also guarantees that a distinct type is generated for the Java IDL language mapping.

Generated by Sybase EAServer 5.0