FPEnvironment_DUMMY.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // FPEnvironment_DUMMY.h
  3. //
  4. // Library: Foundation
  5. // Package: Core
  6. // Module: FPEnvironment
  7. //
  8. // Definition of class FPEnvironmentImpl for platforms that do not
  9. // support IEEE 754 extensions.
  10. //
  11. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  12. // and Contributors.
  13. //
  14. // SPDX-License-Identifier: BSL-1.0
  15. //
  16. #ifndef Foundation_FPEnvironment_DUMMY_INCLUDED
  17. #define Foundation_FPEnvironment_DUMMY_INCLUDED
  18. #include "Poco/Foundation.h"
  19. #include <cmath>
  20. namespace Poco {
  21. class Foundation_API FPEnvironmentImpl
  22. {
  23. protected:
  24. enum RoundingModeImpl
  25. {
  26. FP_ROUND_DOWNWARD_IMPL,
  27. FP_ROUND_UPWARD_IMPL,
  28. FP_ROUND_TONEAREST_IMPL,
  29. FP_ROUND_TOWARDZERO_IMPL
  30. };
  31. enum FlagImpl
  32. {
  33. FP_DIVIDE_BY_ZERO_IMPL,
  34. FP_INEXACT_IMPL,
  35. FP_OVERFLOW_IMPL,
  36. FP_UNDERFLOW_IMPL,
  37. FP_INVALID_IMPL
  38. };
  39. FPEnvironmentImpl();
  40. FPEnvironmentImpl(const FPEnvironmentImpl& env);
  41. ~FPEnvironmentImpl();
  42. FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
  43. void keepCurrentImpl();
  44. static void clearFlagsImpl();
  45. static bool isFlagImpl(FlagImpl flag);
  46. static void setRoundingModeImpl(RoundingModeImpl mode);
  47. static RoundingModeImpl getRoundingModeImpl();
  48. static bool isInfiniteImpl(float value);
  49. static bool isInfiniteImpl(double value);
  50. static bool isInfiniteImpl(long double value);
  51. static bool isNaNImpl(float value);
  52. static bool isNaNImpl(double value);
  53. static bool isNaNImpl(long double value);
  54. static float copySignImpl(float target, float source);
  55. static double copySignImpl(double target, double source);
  56. static long double copySignImpl(long double target, long double source);
  57. private:
  58. static RoundingModeImpl _roundingMode;
  59. };
  60. //
  61. // inlines
  62. //
  63. inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
  64. {
  65. return std::isinf(value) != 0;
  66. }
  67. inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
  68. {
  69. return std::isinf(value) != 0;
  70. }
  71. inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
  72. {
  73. return std::isinf((double) value) != 0;
  74. }
  75. inline bool FPEnvironmentImpl::isNaNImpl(float value)
  76. {
  77. return std::isnan(value) != 0;
  78. }
  79. inline bool FPEnvironmentImpl::isNaNImpl(double value)
  80. {
  81. return std::isnan(value) != 0;
  82. }
  83. inline bool FPEnvironmentImpl::isNaNImpl(long double value)
  84. {
  85. return std::isnan((double) value) != 0;
  86. }
  87. inline float FPEnvironmentImpl::copySignImpl(float target, float source)
  88. {
  89. return copysignf(target, source);
  90. }
  91. inline double FPEnvironmentImpl::copySignImpl(double target, double source)
  92. {
  93. return copysign(target, source);
  94. }
  95. } // namespace Poco
  96. #endif // Foundation_FPEnvironment_DUMMY_INCLUDED