Added ULP base function

This commit is contained in:
Christophe Riccio 2011-03-06 13:39:19 +00:00
parent 29df45a166
commit 0990ac4583
2 changed files with 44 additions and 1 deletions

View File

@ -42,7 +42,7 @@ namespace glm
}//namespace gtx }//namespace gtx
}//namespace glm }//namespace glm
#include "spline.inl" #include "ulp.inl"
namespace glm{using namespace gtx::spline;} namespace glm{using namespace gtx::spline;}

View File

@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-03-07
// Updated : 2011-03-07
// Licence : This source is under MIT License
// File : glm/gtx/ulp.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <cmath>
namespace glm{
namespace gtx{
namespace ulp
{
inline std::size_t ulp
(
double const & a,
double const & b
)
{
std::size_t Count = 0;
double Temp = a;
while((Temp = nextafterf(Temp, b)) != b)
++Count;
return Count;
}
inline std::size_t ulp
(
float const & a,
float const & b
)
{
std::size_t Count = 0;
float Temp = a;
while((Temp = nextafterf(Temp, b)) != b)
++Count;
return Count;
}
}//namespace ulp
}//namespace gtx
}//namespace glm