
Untitled
By: a guest on
Jul 31st, 2012 | syntax:
None | size: 0.60 KB | hits: 12 | expires: Never
Convert 64-bit double to 80-bit double in byte array form in visual studio
inline void ConvertDblToLongDbl(double dbl, unsigned char aCh[10])
{
__int64 ull= *(__int64*)(&dbl);
*(unsigned short*)&aCh[8]= (unsigned short)((ull>>52&0x7FF+15360)| // exponent, from 11 bits to 15 bits
((ull&(__int64)1<<63)?0x8000:0)); // sign, the 16th bit
ull= ull&0xFFFFFFFFFFFFF;
*(__int64*)&aCh[0]= ull|0x8000000000000000;
}
void ConvertDoubleToLongDouble(double value, unsigned char result[10]) {
__asm {
fld value;
mov ebx, result;
fstp tbyte ptr [ebx];
}
}