xtd 0.2.0
Loading...
Searching...
No Matches
box_floating_point.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "box_integer.hpp"
6#include "decimal.hpp"
7#define __XTD_CORE_INTERNAL__
9#undef __XTD_CORE_INTERNAL__
10
12namespace xtd {
41 template<class type_t>
42 class box_floating_point : public xtd::box_integer<type_t> {
43 public:
45 box_floating_point() = default;
47 box_floating_point(const box_floating_point&) = default;
49 box_floating_point& operator =(const box_floating_point&) = default;
51
53
57 static constexpr type_t epsilon = __get_epsilon(type_t{});
60 static constexpr type_t NaN = std::numeric_limits<type_t>::quiet_NaN();
63 static constexpr type_t negative_infinity = -std::numeric_limits<type_t>::infinity();
66 static constexpr type_t positive_infinity = +std::numeric_limits<type_t>::infinity();
68
70
75 static bool is_finite(type_t value) noexcept {return !is_infinity(value);}
79 static bool is_infinity(type_t value) noexcept {return is_negative_infinity(value) || is_positive_infinity(value);}
80
84 static bool is_negative_infinity(type_t value) noexcept {return value <= negative_infinity;}
85
89 static bool is_positive_infinity(type_t value) noexcept {return value >= positive_infinity;}
90
94 static bool is_NaN(type_t value) noexcept {return value != value;}
95
100 static bool is_valid(std::floating_point auto value) noexcept {return !is_NaN(value) && !is_infinity(value) && value >= static_cast<xtd::decimal>(xtd::box_integer<type_t>::min_value) && value <= static_cast<xtd::decimal>(xtd::box_integer<type_t>::max_value);}
102 };
103}
Contains xtd::box_integer class.
Represents a boxed floating point object.
Definition box_floating_point.hpp:42
static bool is_finite(type_t value) noexcept
Determines whether the specified value is finite (zero, subnormal, or normal).
Definition box_floating_point.hpp:75
static constexpr decimal epsilon
Definition box_floating_point.hpp:57
static bool is_NaN(type_t value) noexcept
Returns a value indicating whether the specified number evaluates to not a number.
Definition box_floating_point.hpp:94
static constexpr decimal NaN
Definition box_floating_point.hpp:60
static bool is_positive_infinity(type_t value) noexcept
Returns a value indicating whether the specified number evaluates to positive infinity.
Definition box_floating_point.hpp:89
static bool is_valid(std::floating_point auto value) noexcept
Determines whether the specified floating point value is within the range of type_t.
Definition box_floating_point.hpp:100
static bool is_infinity(type_t value) noexcept
Returns a value indicating whether the specified number evaluates to negative or positive infinity.
Definition box_floating_point.hpp:79
static constexpr decimal positive_infinity
Definition box_floating_point.hpp:66
static bool is_negative_infinity(type_t value) noexcept
Returns a value indicating whether the specified number evaluates to negative infinity.
Definition box_floating_point.hpp:84
static constexpr decimal negative_infinity
Definition box_floating_point.hpp:63
Represents a boxed integer object.
Definition box_integer.hpp:54
static constexpr type_t max_value
Represents the largest possible value of type_t. This field is constant.
Definition box_integer.hpp:69
static constexpr type_t min_value
Represents the smallest possible value of type_t. This field is constant.
Definition box_integer.hpp:72
Contains xtd::decimal type.
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
value_type value
Gets or sets the underlying value.
Definition box.hpp:106