本帖最后由 donkey89 于 2011-7-5 11:01 编辑
找遍了帮助没看到.下面代码计算结果也不对.整数部分就不对,例如输入的是0X1358,计算结果是3982,实际应该是374.87 请帮我看看是哪里出了问题? ldiv_t vcal;
uint16_t *p_adc_value_16;
long vint,vpoint;
p_adc_value_16=(uint16_t *)adc_value[0];
vcal=ldiv((long)(*p_adc_value_16)*(long)2480,(long)0x007fff);
vint=vcal.quot;
vpoint=vcal.rem;
vcal=ldiv(vpoint*(long)100,0x007fff);
vcal.rem=vcal.quot;
vcal.quot=vint;
lcd_print_div(vcal);
|