本帖最后由 victor3l 于 2012-6-27 16:01 编辑
void FirChVotage()
{
xdata char FirVoltage[5] = {0};
xdata ulong tempCode = 0;//存储内码值
xdata ulong tempFilterCode = 0;//对内码值滤波
xdata uint voltage = 0;//存储电压值
tempCode = ReadFromCS1180Channel1();//读通道1的内码值
tempFilterCode = FilterDatChannel1(tempCode);//对通道1的内码值进行滤波
// while(!(CheckWeightStable(tempFilterCode,0)));//对滤波后的值判稳后放到realCode[0]中
voltage = (uint)(tempFilterCode*PRECISION);
ComplexDisp(FirVoltage,voltage,0);
LoadMutiDat(0x76,FirVoltage,5);
DispOn();
}
voltage = (uint)(tempFilterCode*PRECISION);
这里的乘法到底有什么问题,得到的结果完全不理解。这里PRECISION = 0.149,tempFilterCode 是1342左右,但是这里以乘后就是60429。这是怎么回事?
当我在voltage = (uint)(tempFilterCode*PRECISION);之前把tempFilterCode强行赋值1342,在让他们相乘得到的结果是对的,单独显示滤波后的内码值tempFilterCode也是对的,为什么他们自己相乘结果就错了? |