18 #include "boost/integer_traits.hpp" 24 boost::integer_traits<int> ::is_specialized &&
25 boost::integer_traits<unsigned int> ::is_specialized &&
26 sizeof(
float)==
sizeof(
int) &&
27 sizeof(
float)==
sizeof(
unsigned int) &&
28 32 == boost::integer_traits<unsigned int>::digits ,
"FAILED ASSUMPTIONS") ;
35 typedef __int64 Long ;
36 typedef unsigned __int64 ULong ;
45 typedef unsigned long ULong ;
50 typedef long long Long ;
51 typedef unsigned long long ULong ;
53 struct _Longs :
public __Longs<sizeof(double)==sizeof(long)>{};
57 typedef _Longs::Long Long ;
58 typedef _Longs::ULong ULong ;
64 boost::integer_traits<ULong> ::is_specialized &&
65 boost::integer_traits<Long> ::is_specialized &&
66 sizeof(
double)==
sizeof(Long) &&
67 sizeof(
double)==
sizeof(ULong) &&
83 boost::integer_traits<int> ::is_specialized &&
84 boost::integer_traits<unsigned int> ::is_specialized &&
85 sizeof(
float)==
sizeof(
int) &&
86 32 == boost::integer_traits<unsigned int>::digits ,
"FAILED ASSUMPTIONS") ;
91 float i2f (
const int i ) { m_f.i = i ;
return m_f.f ; }
93 int f2i (
const float f ) { m_f.f = f ;
return m_f.i ; }
123 boost::integer_traits<ULong> ::is_specialized &&
124 boost::integer_traits<Long> ::is_specialized &&
125 sizeof(
double)==
sizeof(Long) &&
126 sizeof(
double)==
sizeof(ULong) &&
132 double l2d (
const Long
l ) { m_d.l =
l ;
return m_d.d ; }
134 Long d2l (
const double d ) { m_d.d = d ;
return m_d.l ; }
195 const unsigned short maxULPs )
200 boost::integer_traits<int> ::is_specialized &&
201 boost::integer_traits<unsigned int> ::is_specialized &&
202 sizeof(
float)==
sizeof(
int) &&
203 sizeof(
float)==
sizeof(
unsigned int) &&
204 32 == boost::integer_traits<unsigned int>::digits ,
"FAILED ASSUMPTIONS") ;
211 int ai = caster.f2i ( af ) ;
212 int bi = caster.f2i ( bf ) ;
214 int test = (((
unsigned int)(ai^bi))>>31)-1;
218 int diff = ((( boost::integer_traits<int>::const_min - ai ) & (~test)) | ( ai& test )) - bi ;
220 int maxDiff_ = maxULPs ;
222 int v1 = maxDiff_ + diff ;
223 int v2 = maxDiff_ - diff ;
250 sizeof(
float)==
sizeof(
int) ,
"FAILED ASSUMPTIONS") ;
255 int ai = caster.f2i ( af ) ;
258 return caster.i2f ( ai ) ;
291 const unsigned int maxULPs )
298 boost::integer_traits<ULong> ::is_specialized &&
299 boost::integer_traits<Long> ::is_specialized &&
300 sizeof(
double)==
sizeof(Long) &&
301 sizeof(
double)==
sizeof(ULong) &&
308 Long ai = caster.d2l ( af ) ;
309 Long bi = caster.d2l ( bf ) ;
311 Long
test = (((ULong)(ai^bi))>>63)-1;
315 Long diff = ((( boost::integer_traits<Long>::const_min - ai ) & (~test)) | ( ai& test )) - bi ;
317 Long maxDiff_ = maxULPs ;
319 Long v1 = maxDiff_ + diff ;
320 Long v2 = maxDiff_ - diff ;
348 sizeof(
double)==
sizeof(Long) ,
"FAILED ASSUMPTIONS") ;
353 Long al = caster.d2l ( ad ) ;
356 return caster.l2d ( al ) ;
GAUDI_API bool lomont_compare_float(const float af, const float bf, const unsigned short maxULPs)
equality comparison of float numbers using as the metric the maximal number of Units in the Last Plac...
GAUDI_API float next_float(const float af, const short ulps)
Get the floating number that representation is different with respect to the argument for the certain...
GAUDI_API bool lomont_compare_double(const double af, const double bf, const unsigned int maxULPs)
equality comparison of double numbers using as the metric the maximal number of Units in the Last Pla...
GAUDI_API double next_double(const double af, const short ulps)
Get the floating number that representation is different with respect to the argument for the certain...