Help in Math Conversion
criss87
Posts: 32
Dear all!
Someone can give me a small help in translate the below math operations in netlinx?
void ConvertToFixed( DOUBLE val, U08 v[4] )
{
U32 fixed;
val = val>15.9?15.9:val;
val = val<-15.9?-15.9:val;
fixed = (U32)(((S32)floor(0.5+8388608.0*val)) & 0x0FFFFFFF);
}
many thanks !!
Criss
Someone can give me a small help in translate the below math operations in netlinx?
void ConvertToFixed( DOUBLE val, U08 v[4] )
{
U32 fixed;
val = val>15.9?15.9:val;
val = val<-15.9?-15.9:val;
fixed = (U32)(((S32)floor(0.5+8388608.0*val)) & 0x0FFFFFFF);
}
many thanks !!
Criss
0
Comments
It looks like you may have copied it wrong. v is passed in but never used. But nonetheless, other than the ternary operation which isn't supported in Netlinx, it should just about be the same if you change the types to Netlinx types. I can't guess what the function does with all those magic numbers. Looks like poorly thought out code to me.
Paul
Sent from my iPad using Tapatalk HD