MathExt.h
// MathExt.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2004
#pragma once
#ifndef Ceda_cxUtils_MathExt_H
#define Ceda_cxUtils_MathExt_H
#include "cxUtils.h"
#include <math.h>
namespace ceda
{
const double cxPI = 3.14159265359;
inline double DegToRad(double f) { return f * cxPI/180.0; }
inline double RadToDeg(double f) { return f * 180.0/cxPI; }
template <typename T1, typename T2>
inline bool IsNumericallyEqual(T1 x, T2 y) { return x == y; }
template <typename T>
inline bool IsNumericallyEqual(bool x, T y) { return static_cast<T>(x) == y; }
template <typename T>
inline bool IsNumericallyEqual(T x, bool y) { return x == static_cast<T>(y); }
inline bool IsNumericallyEqual(int32 x, float32 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(float32 x, int32 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(uint32 x, float32 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(float32 x, uint32 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(int64 x, float32 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(float32 x, int64 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(uint64 x, float32 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(float32 x, uint64 y) { return (float64) x == (float64) y; }
inline bool IsNumericallyEqual(int8 x, uint32 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(int8 x, uint64 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(uint32 x, int8 y) { return x == y && y >= 0; }
inline bool IsNumericallyEqual(uint64 x, int8 y) { return x == y && y >= 0; }
inline bool IsNumericallyEqual(int16 x, uint32 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(int16 x, uint64 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(uint32 x, int16 y) { return x == y && y >= 0; }
inline bool IsNumericallyEqual(uint64 x, int16 y) { return x == y && y >= 0; }
inline bool IsNumericallyEqual(int32 x, uint32 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(int32 x, uint64 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(uint32 x, int32 y) { return x == y && y >= 0; }
inline bool IsNumericallyEqual(uint64 x, int32 y) { return x == y && y >= 0; }
inline bool IsNumericallyEqual(int64 x, uint64 y) { return x == y && x >= 0; }
inline bool IsNumericallyEqual(uint64 x, int64 y) { return x == y && y >= 0; }
} // namespace ceda
#endif // include guard