Skip to content

Commit ccbe55f

Browse files
committed
nicer output and fixed doc error
1 parent 6cca24b commit ccbe55f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/getting_started_listing_01.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ int main(int, char**) {
5353
edges can be accessed with methods `lower()` and `upper()`, but the
5454
implementation depends on the axis, please look it up in the reference
5555
*/
56+
std::cout.setf(std::ios_base::fixed);
5657
for (auto it = h.begin(); it != h.end(); ++it) {
5758
const auto bin = it.bin(0_c);
5859
std::cout << "bin " << it.idx(0) << " x in ["
59-
<< bin.lower() << ", " << bin.upper() << "): "
60+
<< std::setprecision(1)
61+
<< std::setw(4) << bin.lower() << ", "
62+
<< std::setw(4) << bin.upper() << "): "
63+
<< std::setprecision(1)
6064
<< it->value() << " +/- "
61-
<< std::sqrt(it->variance())
65+
<< std::setprecision(3) << std::sqrt(it->variance())
6266
<< std::endl;
6367
}
6468

@@ -68,7 +72,7 @@ int main(int, char**) {
6872
bin 1 x in [-0.5, 0.0): 0 +/- 0
6973
bin 2 x in [ 0.0, 0.5): 1 +/- 1
7074
bin 3 x in [ 0.5, 1.0): 0 +/- 0
71-
bin 4 x in [ 1.0, 1.5): 1 +/- 1
75+
bin 4 x in [ 1.0, 1.5): 0 +/- 0
7276
bin 5 x in [ 1.5, 2.0): 0 +/- 0
7377
bin 6 x in [ 2.0, inf): 2 +/- 1.41421
7478
bin -1 x in [-inf, -1): 1 +/- 1

0 commit comments

Comments
 (0)