-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexample001e_algebra_and_constexpr.cpp
More file actions
54 lines (39 loc) · 1.96 KB
/
example001e_algebra_and_constexpr.cpp
File metadata and controls
54 lines (39 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
///////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023. //
// Distributed under the Boost Software License, //
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////
#include <cstdint>
#include <examples/example_decwide_t.h>
#include <math/wide_decimal/decwide_t.h>
#if defined(WIDE_DECIMAL_NAMESPACE)
auto WIDE_DECIMAL_NAMESPACE::math::wide_decimal::example001e_algebra_and_constexpr() -> bool
#else
auto ::math::wide_decimal::example001e_algebra_and_constexpr() -> bool
#endif
{
using local_limb_type = std::uint32_t;
constexpr auto wide_decimal_digits10 = static_cast<std::int32_t>(INT32_C(100));
#if defined(WIDE_DECIMAL_NAMESPACE)
using wide_decimal_type = WIDE_DECIMAL_NAMESPACE::math::wide_decimal::decwide_t<wide_decimal_digits10, local_limb_type, void>;
#else
using wide_decimal_type = ::math::wide_decimal::decwide_t<wide_decimal_digits10, local_limb_type, void>;
#endif
auto result_is_ok = true;
const wide_decimal_type local_quarter_a(wide_decimal_type(static_cast<unsigned>(UINT8_C(25))) / static_cast<unsigned>(UINT8_C(100)));
const wide_decimal_type local_quarter_b(static_cast<float>(0.25L)); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
const auto result_construct_is_ok = (local_quarter_a == local_quarter_b);
result_is_ok = (result_construct_is_ok && result_is_ok);
return result_is_ok;
}
// Enable this if you would like to activate this main() as a standalone example.
#if defined(WIDE_DECIMAL_STANDALONE_EXAMPLE001E_ALGEBRA_AND_CONSTEXPR)
#include <iomanip>
#include <iostream>
auto main() -> int
{
const auto result_is_ok = ::math::wide_decimal::example001e_algebra_and_constexpr();
std::cout << "result_is_ok: " << std::boolalpha << result_is_ok << std::endl;
}
#endif