Skip to content

Commit 8ffda03

Browse files
committed
Add example with variety of values
1 parent 34f6dc4 commit 8ffda03

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

examples/debugger.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2025 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
//
5+
// This example, when run with the pretty printers, shows how various values are represented
6+
7+
#include <boost/decimal/decimal32_t.hpp> // For type decimal32_t
8+
#include <boost/decimal/cmath.hpp> // For nan function to write payload to nans
9+
#include <limits>
10+
11+
int main()
12+
{
13+
using boost::decimal::decimal32_t;
14+
15+
const decimal32_t max {std::numeric_limits<decimal32_t>::max()};
16+
const decimal32_t min {std::numeric_limits<decimal32_t>::min()};
17+
const decimal32_t short_num {"3.14"};
18+
const decimal32_t pos_inf {std::numeric_limits<decimal32_t>::infinity()};
19+
const decimal32_t neg_inf {-std::numeric_limits<decimal32_t>::infinity()};
20+
21+
const decimal32_t qnan {std::numeric_limits<decimal32_t>::quiet_NaN()};
22+
const decimal32_t snan {std::numeric_limits<decimal32_t>::signaling_NaN()};
23+
24+
const decimal32_t payload_nan {boost::decimal::nand32("7")};
25+
26+
// Break Here:
27+
static_cast<void>(max);
28+
static_cast<void>(min);
29+
static_cast<void>(short_num);
30+
static_cast<void>(pos_inf);
31+
static_cast<void>(neg_inf);
32+
static_cast<void>(qnan);
33+
static_cast<void>(snan);
34+
static_cast<void>(payload_nan);
35+
36+
return 0;
37+
}

test/Jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ run ../examples/first_example.cpp ;
214214
run ../examples/basic_arithmetic.cpp ;
215215
run ../examples/to_from_file.cpp ;
216216
run ../examples/addition.cpp ;
217+
run ../examples/debugger.cpp ;
217218

218219
# Test compilation of separate headers
219220
compile compile_tests/bid_conversion.cpp ;

0 commit comments

Comments
 (0)