added the two missing bits to the result when decoding FPE2 values

This commit is contained in:
Denis Ahrens
2013-02-01 01:47:35 +01:00
parent b125097a07
commit 3b87cc972d
2 changed files with 5 additions and 6 deletions

View File

@ -52,7 +52,7 @@ void _ultostr(char *str, UInt32 val)
(unsigned int) val);
}
float _strtof(char *str, int size, int e)
float _strtof(unsigned char *str, int size, int e)
{
float total = 0;
int i;
@ -65,6 +65,8 @@ float _strtof(char *str, int size, int e)
total += str[i] << (size - 1 - i) * (8 - e);
}
total += (str[size-1] & 0x03) * 0.25;
return total;
}
@ -77,9 +79,7 @@ void smc_close(){
}
void printFPE2(SMCVal_t val)
{
/* FIXME: This decode is incomplete, last 2 bits are dropped */
printf("%.0f ", _strtof(val.bytes, val.dataSize, 2));
printf("%.02f ", _strtof(val.bytes, val.dataSize, 2));
}
void printUInt(SMCVal_t val)