...
1 package inf_test
2
3 import (
4 "fmt"
5 "log"
6 )
7
8 import "gopkg.in/inf.v0"
9
10 func ExampleDec_SetString() {
11 d := new(inf.Dec)
12 d.SetString("012345.67890")
13 fmt.Println(d)
14
15 }
16
17 func ExampleDec_Scan() {
18
19
20 d := new(inf.Dec)
21 _, err := fmt.Sscan("184467440.73709551617", d)
22 if err != nil {
23 log.Println("error scanning value:", err)
24 } else {
25 fmt.Println(d)
26 }
27
28 }
29
30 func ExampleDec_QuoRound_scale2RoundDown() {
31
32 x, y := inf.NewDec(10, 0), inf.NewDec(3, 0)
33
34 z := new(inf.Dec).QuoRound(x, y, 2, inf.RoundDown)
35 fmt.Println(z)
36
37 }
38
39 func ExampleDec_QuoRound_scale2RoundCeil() {
40
41 x, y := inf.NewDec(-42, 0), inf.NewDec(400, 0)
42
43 z := new(inf.Dec).QuoRound(x, y, 2, inf.RoundCeil)
44 fmt.Println(z)
45
46 }
47
48 func ExampleDec_QuoExact_ok() {
49
50 x, y := inf.NewDec(1, 0), inf.NewDec(25, 0)
51 z := new(inf.Dec).QuoExact(x, y)
52 fmt.Println(z)
53
54 }
55
56 func ExampleDec_QuoExact_fail() {
57
58 x, y := inf.NewDec(1, 0), inf.NewDec(3, 0)
59 z := new(inf.Dec).QuoExact(x, y)
60 fmt.Println(z)
61
62 }
63
View as plain text