测温补偿测试程序

#include<stdio.h>
#include<math.h>
#define uchar unsigned char
#define R1 10000 // the value of standard resistor is 10000
#define c 0.0001// theroy current
#define Vref 2.5//refrence voltage
#define PGA 2//gain
char *Hex="0123456789ABCDEF";
void PrintHex(long a);

//恒流源波动0.1uA时的测试情况
int main(void)
{
double DM1 = 0x33404e;
double DM2 = 0x52007d;
double DT2 = (DM2/DM1) * R1 * c * PGA * (pow(2,23)-1)/(2 * Vref);
long DT2_int = (long)DT2;//舍弃小数位
printf("Decimal form: ");
printf("%f ",DT2);
printf("Hex form: ");
PrintHex(DT2_int);
printf(" ");
return 0;
}

//函数的嵌套
void PrintHex(long a)//Convert Decimal to Hex and print laster
{
if(!a)
return;
PrintHex(a/16);
char x = Hex[a%16];
printf("%c",Hex[a%16]);
}

原文地址:https://www.cnblogs.com/getyoulove/p/3874294.html