Skip to content

Commit bf4db62

Browse files
authored
Merge pull request #715 from devlights:add-result-in-examles
Add Result in examples (examples/basic/floatop)
2 parents 281fae8 + 2e07e4b commit bf4db62

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

examples/basic/floatop/order_of_computation.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,28 @@ func OrderOfComputation() error {
4141
}
4242

4343
return nil
44+
45+
/*
46+
$ task
47+
task: Task "build" is up to date
48+
task: [run] ./try-golang -onetime
49+
50+
ENTER EXAMPLE NAME: floatop_order_of_computation
51+
52+
[Name] "floatop_order_of_computation"
53+
[Total (float32, float64)] 501.02402 501.02436977016623
54+
[Total (float32, float64)] 501.02417 501.02436977016623
55+
[Total (float32, float64)] 501.0243 501.02436977016623
56+
[Total (float32, float64)] 501.02444 501.02436977016623
57+
[Total (float32, float64)] 501.02475 501.02436977016623
58+
[Total (float32, float64)] 501.02423 501.02436977016623
59+
[Total (float32, float64)] 501.02454 501.02436977016623
60+
[Total (float32, float64)] 501.02466 501.02436977016623
61+
[Total (float32, float64)] 501.02435 501.02436977016623
62+
[Total (float32, float64)] 501.02426 501.02436977016623
63+
64+
65+
[Elapsed] 586.92µs
66+
*/
67+
4468
}

examples/basic/floatop/rounding_error.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,20 @@ func RoundingError() error {
3838
output.Stdoutl("[big.Rat]", v2.FloatString(1)) // 10.0
3939

4040
return nil
41+
42+
/*
43+
$ task
44+
task: [build] go build .
45+
task: [run] ./try-golang -onetime
46+
47+
ENTER EXAMPLE NAME: floatop_rounding_error
48+
49+
[Name] "floatop_rounding_error"
50+
[float64] 9.999999999999831
51+
[big.Rat] 10.0
52+
53+
54+
[Elapsed] 1.32107ms
55+
*/
56+
4157
}

examples/basic/floatop/using_decimal_pkg.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,19 @@ func UsingDecimalPkg() error {
2525
output.Stdoutl("[result]", v.StringFixed(1))
2626

2727
return nil
28+
29+
/*
30+
$ task
31+
task: [build] go build .
32+
task: [run] ./try-golang -onetime
33+
34+
ENTER EXAMPLE NAME: floatop_using_decimal_pkg
35+
36+
[Name] "floatop_using_decimal_pkg"
37+
[result] 10.0
38+
39+
40+
[Elapsed] 549.44µs
41+
*/
42+
2843
}

0 commit comments

Comments
 (0)