Skip to content

Commit ddb865d

Browse files
committed
Add new example to docs
1 parent 1a5982e commit ddb865d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

doc/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* xref:basics.adoc[]
33
* xref:examples.adoc[]
44
** xref:examples.adoc#examples_construction[Basic Construction]
5+
** xref:examples.adoc#examples_basic_math[Basic Arithmetic]
56
** xref:examples.adoc#examples_promotion[Promotion and Mixed Decimal Arithmetic]
67
** xref:examples.adoc#examples_charconv[`<charconv>`]
78
** xref:examples.adoc#examples_generic_programming[Generic Programming]

doc/modules/ROOT/pages/examples.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ Can not construct from invalid string
3333
....
3434
====
3535
36+
[#examples_basic_math]
37+
== Basic Arithmetic
38+
39+
.This https://github.com/cppalliance/decimal/blob/develop/examples/basic_arithmetic.cpp[example] demonstrates the behavior and functionality of arithmetic using a single type
40+
====
41+
[source, c++]
42+
----
43+
include::example$basic_arithmetic.cpp[]
44+
----
45+
46+
.Expected Output:
47+
....
48+
A: -5.123456891234567
49+
B: 3.123456891234567
50+
A + B: -2
51+
abs(A + B): 2
52+
sqrt(abs(A + B)): 1.414213562373095
53+
Wolfram Alpha sqrt(2): 1.414213562373095
54+
....
55+
====
56+
3657
[#examples_promotion]
3758
== Promotion and Mixed Decimal Arithmetic
3859

0 commit comments

Comments
 (0)