M
Michael
Hallo NG,
a few jears ago i made myself in c++ a funktion to convert 4 Byte to one
float variable:
//###########################################################
// Make from 4 Bytes one float variable wich is 4 bytes long
//###########################################################
float CAtgGalvanoMachine::Convert4BytesToFloat(BYTE byte1, BYTE byte2, BYTE
byte3, BYTE byte4)
{
DWORD l,ll,m,e;
float returnvalue=0,mantisse=0;
l = byte1;
l = l << 24;
ll = byte2;
l = l | (ll << 16);
ll = byte3;
l = l | (ll << 8);
ll = byte4;
l = l | ll;
e=l&0x7f800000;
e>>=23;
m=l&0x7fffff;
for(int i=0; i<=23;i++)
{
if(TestBit(m,unsigned int(ldexp(1,i))))
{
mantisse+=float((ldexp(1, i-23)));
}
}
returnvalue=float(ldexp(1+mantisse, e-127));
return returnvalue;
}
Is their now a ready function in the framework?
and for the other way float to 4 bytes?
Regards
Michael
a few jears ago i made myself in c++ a funktion to convert 4 Byte to one
float variable:
//###########################################################
// Make from 4 Bytes one float variable wich is 4 bytes long
//###########################################################
float CAtgGalvanoMachine::Convert4BytesToFloat(BYTE byte1, BYTE byte2, BYTE
byte3, BYTE byte4)
{
DWORD l,ll,m,e;
float returnvalue=0,mantisse=0;
l = byte1;
l = l << 24;
ll = byte2;
l = l | (ll << 16);
ll = byte3;
l = l | (ll << 8);
ll = byte4;
l = l | ll;
e=l&0x7f800000;
e>>=23;
m=l&0x7fffff;
for(int i=0; i<=23;i++)
{
if(TestBit(m,unsigned int(ldexp(1,i))))
{
mantisse+=float((ldexp(1, i-23)));
}
}
returnvalue=float(ldexp(1+mantisse, e-127));
return returnvalue;
}
Is their now a ready function in the framework?
and for the other way float to 4 bytes?
Regards
Michael