获取double的最大精度

来源:互联网 时间:2016-11-10

 1 #typedef DyDouble double

2 #typedef DyInt64 int

3 DyDouble GetMaxPrecision(DyDouble db)

4 {

5 assert( sizeof(DyDouble ) == sizeof( DyInt64 ) );

6 DyInt64 exp = ((*((DyInt64*)& db) >>52) & 0x7ff) - 32;

7 if( exp <=0 ) return 1e-299;

8 exp = expDelta << 52;

9 DyDouble reErr = *((DyDouble*)&exp );

10 return reErr;

11 }

 

相关阅读:
Top