()
| 87 | } |
| 88 | |
| 89 | func ExampleErrDecimal() { |
| 90 | c := apd.BaseContext.WithPrecision(5) |
| 91 | ed := apd.MakeErrDecimal(c) |
| 92 | d := apd.New(10, 0) |
| 93 | fmt.Printf("%s, err: %v\n", d, ed.Err()) |
| 94 | ed.Add(d, d, apd.New(2, 1)) // add 20 |
| 95 | fmt.Printf("%s, err: %v\n", d, ed.Err()) |
| 96 | ed.Quo(d, d, apd.New(0, 0)) // divide by zero |
| 97 | fmt.Printf("%s, err: %v\n", d, ed.Err()) |
| 98 | ed.Sub(d, d, apd.New(1, 0)) // attempt to subtract 1 |
| 99 | // The subtraction doesn't occur and doesn't change the error. |
| 100 | fmt.Printf("%s, err: %v\n", d, ed.Err()) |
| 101 | // Output: |
| 102 | // 10, err: <nil> |
| 103 | // 30, err: <nil> |
| 104 | // Infinity, err: division by zero |
| 105 | // Infinity, err: division by zero |
| 106 | } |
| 107 | |
| 108 | // ExampleRoundToIntegralExact demonstrates how to use RoundToIntegralExact to |
| 109 | // check if a number is an integer or not. Note the variations between integer |
nothing calls this directly
no test coverage detected
searching dependent graphs…