Hi Lambtron,
Whatever u have posted, need some modification.
The correct code is as below
char GetLsb( float *f )
{
int a = 5 ;
return ((char *)f)[ (((char*)&a)[0] == 5)) ? 0 : (sizeof(float)-1) ];
}
please i want to convert a log routine from basic to c and i know that there is a log function but i need it detailed as it in the basic code
can anyone convert this for me please
---------------------------------------------------------------
' Create some variables for use with LN and LOG
Dim LOG_VALUE as Float
Dim LOG_POWER as Float
Dim LOG_TEMP as Float
Dim LOG_X as Float
Dim LOG_FACTOR as Float
Dim LOG_XSQR as Float
Dim LOG_N as Byte
Dim LOG_TEMP2 as Byte
LNc:
' We can't have ln(1) so we must return a zero if it is
If LOG_VALUE.Byte0 = 0 Then LOG_VALUE = 0: Return
' The difference between LOG_N.BYTE0 and $7E will be the
' amount of 2^LOG_N's that we want to multiply times ln(2)
If LOG_VALUE.Byte0 <= $7E Then
LOG_N = $7E - LOG_VALUE.Byte0
LOG_FACTOR = -0.69314718 * LOG_N
Else
LOG_N = LOG_VALUE.Byte0 - $7E
LOG_FACTOR = 0.69314718 * LOG_N
Endif
LOG_VALUE.Byte0 = $7E
' Begin the taylor series expansion
' ln(1+LOG_X) = LOG_X - (LOG_X^2/2) + (LOG_X^3/3) -+...