The most commonly used Long variable to BCD code

Publisher:安静的夜晚Latest update time:2015-10-08 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Convert the long integer variable sec into a single-byte BCD code and store it in the display buffer array
unsigned char a[10];
void long_to_bcd(unsigned long sec)
{
a[0] = sec % 10; // Get the ones digit
a[1] = sec / 10 % 10; // Get the tens digit
a[2] = sec / 100 % 10; // Get the hundreds digit
a[3] = sec / 1000 % 10; // Get the thousands digit
a[4] = sec / 10000 % 10; // Get the ten thousand digit
a[5] = sec / 100000 % 10; // Get the hundred thousand digit
a[6] = sec / 1000000 % 10; // Get the million digit
a[7] = sec / 10000000 % 10; // Get the ten million digit
a[8] = sec / 100000000 % 10; // get the billionth digit
a[9] = sec / 1000000000 % 10; // get the billionth digit
}
Reference address:The most commonly used Long variable to BCD code

Previous article:Single LED indicator flashing control
Next article:Common algorithms for microcontroller data collection

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号