⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bin2bcd.c

📁 10进制to BCD转换算法
💻 C
字号:
// 	*********************************************************************************							
//  *    		Function: 		DecimalToBcdAscii									*
//	*			Description:	Convert decimal value to 3 digit BCD ASCII value	*
//  *********************************************************************************
unsigned char Hundreds,Tens,Ones;
void DecimalToBcdAscii(signed short DecimalValue)
	{
   	Hundreds = 0;							// Initialize BCD values
  	Tens = 0;
  	Ones = 0;
  
  	Hundreds:								// Hundreds
    	DecimalValue = DecimalValue - 100;
      	if (DecimalValue < 0)   
      		{
         	goto Tens1;
         	}
      	Hundreds = Hundreds + 1;			// Increment Hundreds count
      	goto Hundreds; 	
  	Tens1:									// Tens
    	DecimalValue = DecimalValue + 100;
  	Tens2:
      	DecimalValue = DecimalValue - 10;
      	if (DecimalValue < 0)   
      		{
        	goto Ones1;
        	}
      	Tens = Tens + 1;					// Increment Tens count
      	goto Tens2;    
  	Ones1:									// Ones
    	DecimalValue = DecimalValue + 10;
  	Ones2:
      	DecimalValue = DecimalValue - 1;
      	if (DecimalValue < 0)   
      		{
         	goto AddAsciiOffset;
         	}
      	Ones = Ones + 1;					// Increment Ones count
      	goto Ones2;    
   	AddAsciiOffset:							// Add ASCII offset
      	Hundreds = Hundreds + 48;
      	Tens = Tens + 48;
      	Ones = Ones + 48; 
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -