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) |
_vbi_inline vbi_bool | vbi_bcd_digits_greater (unsigned int bcd, unsigned int maximum) |
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.
Macro Definition Documentation
Function Documentation
_vbi_inline unsigned int vbi_dec2bcd |
( |
unsigned int |
dec | ) |
|
- Parameters:
-
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:
-
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:
-
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.
_vbi_inline vbi_bool vbi_bcd_digits_greater |
( |
unsigned int |
bcd, |
|
|
unsigned int |
maximum |
|
) |
| |
- Parameters:
-
bcd | Unsigned BCD number. |
maximum | Unsigned maximum value. |
Compares an unsigned packed bcd number digit-wise against a maximum value, for example 0x295959. maximum can contain digits 0x0 ... 0xF.
- Returns:
TRUE
if any digit of bcd is greater than the corresponding digit of maximum.
- Since:
- 0.2.28