Skip to content

Commit 90105f6

Browse files
authored
Merge pull request #1250 from cppalliance/basics
Reduce duplication on the basics doc page
2 parents a770e8d + 53513f2 commit 90105f6

File tree

3 files changed

+28
-126
lines changed

3 files changed

+28
-126
lines changed

doc/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*** xref:examples.adoc#examples_std_format[`<format>`]
1212
*** xref:examples.adoc#examples_print[`<print>`]
1313
* xref:financial_examples.adoc[]
14+
** xref:financial_examples.adoc#examples_money_parsing[Parsing Pricing Data from File]
1415
** xref:financial_examples.adoc#examples_boost_math[Boost.Math Integration]
1516
* xref:api_reference.adoc[]
1617
** xref:api_reference.adoc#api_ref_types[Types]

doc/modules/ROOT/pages/basics.adoc

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ This is designed to reduce confusion (e.g. what would be the resulting sign of `
4343
boost::decimal::decimal32_t a {1, 1}; // constructs 1e1 = 10
4444
boost::decimal::decimal32_t b {-2, -1}; // constructs -2e-2 or -0.2
4545
boost::decimal::decimal32_t c {2U, -1, construction_sign::negative}; // also constructs -2e-1 or -0.2 (Note: The coefficient must be an unsigned type)
46-
boost::decimal::decimal32_t e {5, 5}; // constructs 5x10^5
47-
boost::decimal::decimal32_t f {1234, -3} // constructs 1.234 or 1234x10^-3
46+
boost::decimal::decimal32_t d {5, 5}; // constructs 5x10^5
47+
boost::decimal::decimal32_t e {1234, -3} // constructs 1.234 or 1234x10^-3
4848
----
4949

5050
Overflow and underflow are handled the same way that they are with binary floating point numbers i.e. they will construct an infinity or a zero.
@@ -57,13 +57,12 @@ boost::decimal::decimal64_t underflow_value {100, -10000}; // Constructs 0
5757

5858
=== Construction from Integer
5959

60-
A decimal number can be explicitly or implicitly constructed from an integer.
60+
A decimal number can be explicitly constructed from an integer.
6161
For example:
6262

6363
[source, c++]
6464
----
65-
boost::decimal::decimal64_t g = 1;
66-
boost::decimal::decimal32_t h {-4};
65+
boost::decimal::decimal32_t f {-4};
6766
----
6867

6968
=== Construction from Binary Floating Point
@@ -79,34 +78,14 @@ boost::decimal::decimal128_t pi {3.14};
7978
Construction from non-finite values (e.g. `std::numeric_limits<double>::quiet_NaN()`) will yield the same non-finite value in the resulting decimal value.
8079
Overflow or underflow will construct infinity or 0.
8180

82-
NOTE: Due to the differences in decimal and binary floating point numbers there may be a difference in the resulting representation in decimal format, and thus it is not recommended to construct from binary floating point numbers
81+
IMPORTANT: Due to the differences in decimal and binary floating point numbers there may be a difference in the resulting representation in decimal format, and thus it is not recommended to construct from binary floating point numbers
8382

84-
== Fundamental Operations
85-
86-
The fundamental operations of numerical types (e.g. `>`, `==`, `+`, etc.) are overloaded.
87-
88-
[source, c++]
89-
----
90-
#include <boost/decimal.hpp>
91-
#include <cassert>
83+
For more information see: xref:examples.adoc#examples_construction[Basic Construction]
9284

93-
int main()
94-
{
95-
constexpr boost::decimal::decimal32_t lhs {5};
96-
constexpr boost::decimal::decimal32_t rhs {1, -1};
97-
98-
assert(lhs > rhs);
99-
assert(lhs != rhs);
100-
assert(lhs + rhs > lhs);
101-
102-
auto new_lhs {lhs}; // Using auto is safe when constructring from existing decimal values
103-
new_lhs += lhs;
104-
105-
assert(lhs < new_lhs);
85+
== Fundamental Operations
10686

107-
return 0;
108-
}
109-
----
87+
The fundamental operations of numerical types (e.g. `>`, `==`, `+`, etc.) are provided for each type, to include mixed type arithmetic (e.g. `decimal32_t` + `decimal64_t`), and between integers and decimal types.
88+
For more information see: xref:examples.adoc#examples_promotion[Promotion and Mixed Decimal Arithmetic].
11089

11190
== Rounding
11291

doc/package-lock.json

Lines changed: 18 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)