Name
BCD arithmetic -- BCD arithmetic for Teletext page numbers.
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.
Details
vbi_pgno
Teletext or Closed Caption page number. For Teletext pages
this is a bcd number in range 0x100 ... 0x8FF. Page numbers
containing digits 0xA to 0xF are reserved for various system
purposes, these pages are not intended for display.
Closed Caption page numbers between 1 ... 8 correspond
to the four Caption and Text channels:
vbi_subno
This is the subpage number only applicable to Teletext pages,
a BCD number in range 0x00 ... 0x99. On special 'clock' pages
(for example listing the current time in different time zones)
it can assume values between 0x0000 ... 0x2359 expressing
local time. These are not actually subpages.
VBI_ANY_SUBNO
#define VBI_ANY_SUBNO 0x3F7F |
VBI_NO_SUBNO
#define VBI_NO_SUBNO 0x3F7F |
vbi_dec2bcd ()
unsigned int vbi_dec2bcd (unsigned int dec); |
Converts a decimal number between 0 ... 999 to a bcd number in range
number 0x000 ... 0x999. Extra digits in the input will be discarded.
vbi_bcd2dec ()
unsigned int vbi_bcd2dec (unsigned int bcd); |
Converts a bcd number between 0x000 ... 0xFFF to a decimal number
in range 0 ... 999. Extra digits in the input will be discarded.
vbi_add_bcd ()
unsigned int vbi_add_bcd (unsigned int a,
unsigned int b); |
Adds two bcd numbers, returning a bcd sum. The result will be in
range 0x00000000 ... 0xFFFFFFFF, discarding carry and extra digits
in the inputs. To subtract you can add the two's complement,
e. g. -0x1 = +0x99999999.
vbi_is_bcd ()
Tests if bcd forms a valid BCD number.