Subj : Re: I need a routine to convert a real48 type into a double To : borland.public.cpp.borlandcpp From : E. Kali Date : Mon Aug 08 2005 10:33 am Hi, I've found the definition of the Real48 on the internet. So i wrote the following function. /*************************************************************************** * Function : ConvertReal48ToDouble * Parameter(s) : szReal48Value - reald48 Value * Return value : double - converted real 48 value * Description : Converts a real48 value to double. * * NOTE: REAL48 format * s f e * bits 47 48...8 7..0 * * s (e-129) * v = (-1) * 2 * (1.f ) * * If e = 0, then v = 0. * ****************************************************************************/ double COxymonfilereader::ConvertReal48ToDouble(unsigned char szReal48Value[6]) { double fResult(0); //strip the data out of real48 type int E( (int) szReal48Value[0]); int S( (int) szReal48Value[5] & 0x80); int F(((int) szReal48Value & 0x7FFFF0)>>4); if(E>0 && E<=255){ float f(0); char szStrVal[10]; _snprintf(szStrVal, 10, "1.%d",F); f = atof(szStrVal); fResult = pow(-1.0,S) * pow(2.0,(E - 129)) * f; }//if(E>0 and E<=255) return fResult; } It seems to work! What do you think about this. "Ed Mulroy" wrote in message news:42f3e243$1@newsgroups.borland.com... >> function Real48ToDouble(value: TReal48__): Double; > > What is 'value'? > > . Ed > >> Tales Aguiar wrote in message >> news:42f3aebb@newsgroups.borland.com... >>I don't now if has a more easy way. I would create a function in .pas file >> like... >> >> unit XXX; >> >> interface >> >> type >> TReal48__ = packed array[0..6] of byte; >> >> function Real48ToDouble(value: TReal48__): Double; >> >> implementation >> >> function Real48ToDouble(value: TReal48__): Double; >> type >> PReal48 = ^Real48; >> begin >> result := PReal48(@value)^; >> end; >> >> end. >> >> >> and use it... > > .