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

View File

@ -98,5 +98,4 @@ kern_return_t SMCClose(io_connect_t conn);
void smc_init(); void smc_init();
void smc_close(); void smc_close();
float _strtof(char *str, int size, int e); float _strtof(unsigned char *str, int size, int e);