Mikroelektronika MIKROE-350 データシート

ページ / 526
Dec2Bcd
Bcd2Dec16
483
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub function Dec2Bcd(dim decnum as byteas byte
Returns
Converted BCD value.
Description
Converts input number to its appropriate BCD representation. 
Parameters : 
decnum:
number to be converted 
Requires
Nothing.
Example
dim a, b as byte
...
a = 22
b = Dec2Bcd(a) ' b equals 34
Prototype
sub function Bcd2Dec16(dim bcdnum as wordas word
Returns
Converted decimal value.
Description
Converts 16-bit BCD numeral to its decimal equivalent.
Parameters : 
bcdnum:
16-bit BCD numeral to be converted 
Requires
Nothing.
Example
dim a, b as word
...
a = 0x1234        ' a equals 4660
b = Bcd2Dec16(a)  ' b equals 1234