()
| 65 | } |
| 66 | |
| 67 | func ExampleContext_Quantize() { |
| 68 | input, _, _ := apd.NewFromString("123.45") |
| 69 | output := new(apd.Decimal) |
| 70 | c := apd.BaseContext.WithPrecision(10) |
| 71 | for i := int32(-3); i <= 3; i++ { |
| 72 | res, _ := c.Quantize(output, input, i) |
| 73 | fmt.Printf("%2v: %s", i, output) |
| 74 | if res != 0 { |
| 75 | fmt.Printf(" (%s)", res) |
| 76 | } |
| 77 | fmt.Println() |
| 78 | } |
| 79 | // Output: |
| 80 | // -3: 123.450 |
| 81 | // -2: 123.45 |
| 82 | // -1: 123.5 (inexact, rounded) |
| 83 | // 0: 123 (inexact, rounded) |
| 84 | // 1: 1.2E+2 (inexact, rounded) |
| 85 | // 2: 1E+2 (inexact, rounded) |
| 86 | // 3: 0E+3 (inexact, rounded) |
| 87 | } |
| 88 | |
| 89 | func ExampleErrDecimal() { |
| 90 | c := apd.BaseContext.WithPrecision(5) |
nothing calls this directly
no test coverage detected
searching dependent graphs…