Main Page   Modules   Data Structures   Data Fields   Related Pages   Examples   Search  

BCD arithmetic for Teletext page numbers
[Data Service Decoder]


Functions

static_inline unsigned int vbi_dec2bcd (unsigned int dec)
static_inline unsigned int vbi_bcd2dec (unsigned int bcd)
static_inline unsigned int vbi_add_bcd (unsigned int a, unsigned int b)
static_inline vbi_bool vbi_is_bcd (unsigned int bcd)

Detailed Description

Teletext page numbers are expressed as binary coded decimal numbers in range 0x100 to 0x8FF. The bcd format encodes one decimal digit in every hex nibble (four bits) of the number. Page numbers containing digits 0xA to 0xF are reserved for various system purposes and not intended for display.

Function Documentation

static_inline unsigned int vbi_dec2bcd unsigned int    dec
 

Parameters:
dec  Decimal number.
Converts a decimal number between 0 ... 999 to a bcd number in range 0x000 ... 0x999. Extra digits in the input will be discarded.

Returns:
BCD number.

static_inline unsigned int vbi_bcd2dec unsigned int    bcd
 

Parameters:
bcd  BCD number.
Converts a bcd number between 0x000 ... 0xFFF to a decimal number in range 0 ... 999. Extra digits in the input will be discarded.

Returns:
Decimal number. The result is undefined when the bcd number contains hex digits 0xA ... 0xF.

static_inline unsigned int vbi_add_bcd unsigned int    a,
unsigned int    b
 

Parameters:
a  BCD number.
b  BCD number.
Adds two bcd numbers, returning a bcd sum. The result will be in range 0x0000 0000 ... 0x9999 9999, discarding carry and extra digits in the inputs. To subtract you can add the complement, e. g. -0x1 = +0x9999 9999.

Returns:
BCD number. The result is undefined when the bcd number contains hex digits 0xA ... 0xF.

static_inline vbi_bool vbi_is_bcd unsigned int    bcd
 

Parameters:
bcd  BCD number.
Tests if bcd forms a valid BCD number.

Returns:
FALSE if bcd contains hex digits 0xA ... 0xF.


Generated on Sat Oct 12 17:49:56 2002 for ZVBI Library by doxygen1.2.15