Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/OpenEXR/Imath/ImathFun.h  view on Meta::CPAN



inline int
mods (int x, int y)
{
    return (x >= 0)? ((y >= 0)?  ( x % y):  ( x % -y)):
		     ((y >= 0)? -(-x % y): -(-x % -y));
}


//
// Integer division and remainder where the
// remainder of x/y is always positive:
//
//	divp(x,y) == floor (double(x) / double (y))
//	modp(x,y) == x - y * divp(x,y)
// 

inline int
divp (int x, int y)
{
    return (x >= 0)? ((y >= 0)?  (     x  / y): -(      x  / -y)):
		     ((y >= 0)? -((y-1-x) / y):  ((-y-1-x) / -y));
}


inline int
modp (int x, int y)
{
    return x - y * divp (x, y);
}

//----------------------------------------------------------
// Successor and predecessor for floating-point numbers:
//
// succf(f)     returns float(f+e), where e is the smallest
//              positive number such that float(f+e) != f.
//
// predf(f)     returns float(f-e), where e is the smallest
//              positive number such that float(f-e) != f.
// 
// succd(d)     returns double(d+e), where e is the smallest
//              positive number such that double(d+e) != d.
//
// predd(d)     returns double(d-e), where e is the smallest
//              positive number such that double(d-e) != d.
//
// Exceptions:  If the input value is an infinity or a nan,
//              succf(), predf(), succd(), and predd() all
//              return the input value without changing it.
// 
//----------------------------------------------------------

IMATH_EXPORT float succf (float f);
IMATH_EXPORT float predf (float f);

IMATH_EXPORT double succd (double d);
IMATH_EXPORT double predd (double d);

//
// Return true if the number is not a NaN or Infinity.
//

inline bool 
finitef (float f)
{
    union {float f; int i;} u;
    u.f = f;

    return (u.i & 0x7f800000) != 0x7f800000;
}

inline bool 
finited (double d)
{
    union {double d; Int64 i;} u;
    u.d = d;

    return (u.i & 0x7ff0000000000000LL) != 0x7ff0000000000000LL;
}


IMATH_INTERNAL_NAMESPACE_HEADER_EXIT

#endif // INCLUDED_IMATHFUN_H



( run in 2.210 seconds using v1.01-cache-2.11-cpan-f0fbb3f571b )