BCD arithmetic for Teletext page numbers
[High Level Decoding]


Functions

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

Detailed Description

Teletext page numbers are expressed as packed 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

vbi_inline unsigned int vbi_dec2bcd unsigned int  dec  ) 
 

Parameters:
dec Decimal number.
Converts a two's complement binary between 0 ... 999 to a packed bcd number in range 0x000 ... 0x999. Extra digits in the input will be discarded.

Returns:
BCD number.

vbi_inline unsigned int vbi_bcd2dec unsigned int  bcd  ) 
 

Parameters:
bcd BCD number.
Converts a packed bcd number between 0x000 ... 0xFFF to a two's complement binary 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.

vbi_inline unsigned int vbi_add_bcd unsigned int  a,
unsigned int  b
 

Parameters:
a BCD number.
b BCD number.
Adds two packed bcd numbers, returning a packed bcd sum. Arguments and result are in range 0xF000 0000 ... 0x0999 9999, that is -10**7 ... +10**7 - 1 in decimal notation. To subtract you can add the 10's complement, e. g. -1 = 0xF999 9999.

Returns:
Packed bcd number. The result is undefined when any of the arguments contain hex digits 0xA ... 0xF.

vbi_inline vbi_bool vbi_is_bcd unsigned int  bcd  ) 
 

Parameters:
bcd BCD number.
Tests if bcd forms a valid BCD number. The argument must be in range 0x0000 0000 ... 0x0999 9999.

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


Generated on Sat Dec 1 10:04:03 2007 for ZVBI Library by  doxygen 1.4.6